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 | |
Nirnimesh
2011/03/20 09:14:06
nit: Please leave a blank line after all the syste
imasaki1
2011/03/20 16:17:16
Done.
| |
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): | |
Nirnimesh
2011/03/20 09:14:06
nit: use single underscore
imasaki1
2011/03/20 16:17:16
Done.
| |
17 """Reads CSV file for test and returns a media test matrix object. | |
18 | |
19 Returns: | |
20 a media test matrix. | |
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') | |
Nirnimesh
2011/03/20 09:14:06
use os.pardir instead of '..'
imasaki1
2011/03/20 16:17:16
Done.
| |
25 matrix.ReadData(data_file) | |
26 return matrix | |
27 | |
28 def testGenerateAllMediaInfosInCompactForm(self): | |
29 matrix = self.__ReadCSVFile() | |
30 # Get video data only case. | |
31 media_test_matrix_list = matrix.GenerateAllMediaInfosInCompactForm(True) | |
32 self.assertEqual(len(media_test_matrix_list), 249, | |
33 "total number of elements in the returned list is wrong") | |
34 # Get all media data. | |
35 media_test_matrix_list = matrix.GenerateAllMediaInfosInCompactForm(False) | |
36 self.assertEqual(len(media_test_matrix_list), 466, | |
37 "total number of elements in the returned list is wrong") | |
38 mobile_test_info = MediaTestMatrix.LookForMediaInfoInCompactFormByNickName( | |
39 media_test_matrix_list, 'mobile0.webm') | |
40 self.assertEqual(mobile_test_info[1], 'mobile0.webm', | |
41 "the nickname of the returned element is wrong") | |
42 | |
43 def testGenerateAllMediaInfos(self): | |
44 matrix = self.__ReadCSVFile() | |
45 # Get video data only case. | |
46 media_test_matrix_list = matrix.GenerateAllMediaInfos(True) | |
47 self.assertEqual(len(media_test_matrix_list), 249, | |
48 "total number of elements in the returned list is wrong") | |
49 # Get all media data. | |
50 media_test_matrix_list = matrix.GenerateAllMediaInfos(False) | |
51 self.assertEqual(len(media_test_matrix_list), 466, | |
52 "total number of elements in the returned list is wrong") | |
Nirnimesh
2011/03/20 09:14:06
nit: use single quote char ' please
Repeat elsewhe
imasaki1
2011/03/20 16:17:16
Done.
| |
53 (info, url, link, tag, is_video, nickname) = ( | |
54 matrix.GenerateRandomMediaInfo()) | |
55 self.assertTrue(info is not None, | |
56 "randomly generated media info does not have spec") | |
57 self.assertTrue(url is not None, | |
58 "randomly generated media info does not have url") | |
59 self.assertTrue(link is not None, | |
60 "randomly generated media info does not have link") | |
61 self.assertTrue(tag is not None, | |
62 "randomly generated media info does not have tag") | |
63 self.assertTrue(nickname is not None, | |
64 "randomly generated media info does not have nickname") | |
65 | |
Nirnimesh
2011/03/20 09:14:06
leave another blank line here.
Need 2 blank lines
imasaki1
2011/03/20 16:17:16
Done.
| |
66 if __name__ == '__main__': | |
67 unittest.main() | |
OLD | NEW |