OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
2 | |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
7 import os | |
8 import random | |
9 import unittest | |
10 from media_test_matrix import MediaTestMatrix | |
11 | |
12 | |
13 class MediaTestMatrixTest(unittest.TestCase): | |
14 """Unit test for MediaTestMatrix class.""" | |
15 | |
16 def __readCSVFile(self): | |
dennis_jeffrey
2011/03/18 17:47:50
In the function name, capitalize the "r" at the be
imasaki1
2011/03/18 21:54:25
Done also make this private
| |
17 """read CSV file for test and returns a media test matrix object. | |
dennis_jeffrey
2011/03/18 17:47:50
Capitalize the "r" in "read" and change it to "Rea
imasaki1
2011/03/18 21:54:25
Done.
| |
18 | |
19 Returns: | |
20 a media test matrix | |
dennis_jeffrey
2011/03/18 17:47:50
Capitalize the starting "a", and add a period at t
imasaki1
2011/03/18 21:54:25
Done.
| |
21 """ | |
22 matrix = MediaTestMatrix() | |
23 # Pyauto.DataDir() method is not used to avoid dependency to pyauto. | |
24 data_file = os.path.join('..', 'data', 'media', 'media_matrix_data.csv') | |
25 matrix.ReadData(data_file) | |
26 return matrix | |
27 | |
28 def testGenerateAllMediaInfosInCompactForm(self): | |
29 matrix = self.__readCSVFile() | |
30 media_test_matrix_list = matrix.GenerateAllMediaInfosInCompactForm(True) | |
31 self.assertEqual(len(media_test_matrix_list), 240) | |
32 mobile_test_info = MediaTestMatrix.LookForMediaInfoByNickName( | |
33 media_test_matrix_list, "mobile0.webm") | |
dennis_jeffrey
2011/03/18 17:47:50
When the function call in the previous line doesn'
imasaki1
2011/03/18 21:54:25
Done.
| |
34 self.assertEqual(mobile_test_info[1], "mobile0.webm") | |
dennis_jeffrey
2011/03/18 17:47:50
Prefer single quotes to double quotes in strings,
dennis_jeffrey
2011/03/18 17:47:50
Before accessing position 1 of the mobile_test_inf
imasaki1
2011/03/18 21:54:25
Done.
imasaki1
2011/03/18 21:54:25
Done.
imasaki1
2011/03/18 21:54:25
Done.
| |
35 | |
36 def testGenerateAllMediaInfos(self): | |
37 matrix = self.__readCSVFile() | |
38 media_test_matrix_list = matrix.GenerateAllMediaInfos(True) | |
39 self.assertEqual(len(media_test_matrix_list), 240) | |
40 (info, url, link, tag, | |
41 is_video, nickname) = matrix.GenerateRandomMediaInfo() | |
dennis_jeffrey
2011/03/18 17:47:50
I think lines 40-41 might look better like this:
imasaki1
2011/03/18 21:54:25
Done.
| |
42 self.assertTrue(info is not None) | |
dennis_jeffrey
2011/03/18 17:47:50
Thanks for adding these extra tests. Could you al
imasaki1
2011/03/18 21:54:25
Done.
| |
43 | |
44 if __name__ == '__main__': | |
45 unittest.main() | |
OLD | NEW |