OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 import unittest | |
7 import shutil | |
8 import os | |
dennis_jeffrey
2011/08/25 00:36:46
Reverse the order of the above 3 lines to put them
imasaki1
2011/08/25 23:57:03
Done.
| |
9 | |
10 from trend_graph import TrendGraph | |
11 | |
12 | |
13 class TestTrendGraph(unittest.TestCase): | |
14 | |
15 def testUpdate(self): | |
16 test_graph_file_path = os.path.join('test_data', 'graph.html') | |
17 test_graph_file_backup_path = os.path.join('test_data', 'graph.html.bk') | |
18 shutil.copyfile(test_graph_file_path, test_graph_file_backup_path) | |
19 trend_graph = TrendGraph(test_graph_file_path) | |
20 data_map = {} | |
21 data_map['whole'] = (str(1), 'undefined', 'undefined') | |
22 data_map['skip'] = (str(2), 'undefined', 'undefined') | |
23 data_map['nonskip'] = (str(3), 'undefined', 'undefined') | |
24 data_map['passingrate'] = (str(4), 'undefined', 'undefined') | |
25 | |
26 trend_graph.Update('2008,1,1,13,45,00', data_map) | |
27 # Assert the result graph from the file. | |
28 f = open(test_graph_file_path) | |
29 lines2 = f.readlines() | |
30 f.close() | |
31 lineCount = 0 | |
32 for line in lines2: | |
33 if '2008,1,1,13,45,00' in line: | |
34 lineCount += 1 | |
35 self.assertEqual(lineCount, 2) | |
36 # Recover the original file. | |
37 shutil.copyfile(test_graph_file_backup_path, test_graph_file_path) | |
dennis_jeffrey
2011/08/25 00:36:46
It's hacky to save the original graph file and the
imasaki1
2011/08/25 23:57:03
Created back up file and changed the code to copy
dennis_jeffrey
2011/08/26 19:01:26
This is better, but the approach of having a backu
| |
OLD | NEW |