OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2013 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 json | |
7 import os | |
8 import unittest | |
9 | |
10 from availability_finder import AvailabilityFinder | |
11 from compiled_file_system import CompiledFileSystem | |
12 from object_store_creator import ObjectStoreCreator | |
13 from test_branch_utility import TestBranchUtility | |
14 from test_file_system import TestFileSystem | |
15 | |
16 def _LoadJSON(name, mode='rb'): | |
17 return json.load( | |
18 open(os.path.join('test_data', 'availability_finder', name), mode)) | |
19 | |
20 def _CreateFileSystem(version): | |
21 branch = _GetBranchNumberForVersion(version) | |
22 return TestFileSystem(_LoadJSON('test_avail_filesystem.json')[branch]) | |
23 | |
24 def _GetBranchNumberForVersion(version): | |
25 return _LoadJSON('test_avail_branch_list.json')[str(version)] | |
26 | |
27 class AvailabilityInfo(object): | |
not at google - send to devlin
2013/06/05 00:24:09
this isn't used anywhere -
generally speaking ple
epeterson
2013/06/17 20:05:49
Done.
| |
28 def __init__(self, channel, version): | |
29 self.channel = channel | |
30 self.version = version | |
31 | |
32 class _FakeChromeVersionUtility(object): | |
33 def GetLatestVersionNumber(self): | |
34 return 28 | |
35 | |
36 def GetBranchNumberForVersion(self, version): | |
37 return _GetBranchNumberForVersion(version) | |
38 | |
39 class AvailabilityFinderTest(unittest.TestCase): | |
40 def setUp(self): | |
41 self._avail_ds_factory = AvailabilityFinder.Factory( | |
42 ObjectStoreCreator.ForTest(), | |
43 CompiledFileSystem.Factory( | |
44 TestFileSystem(_LoadJSON('test_avail_filesystem.json')['trunk']), | |
not at google - send to devlin
2013/06/05 00:24:09
put this file system in python not JSON.
epeterson
2013/06/17 20:05:49
Done, at least for the tests that I added. Should
not at google - send to devlin
2013/06/19 15:57:37
Nah don't worry about it, certainly not in this pa
| |
45 ObjectStoreCreator.ForTest()), | |
46 TestBranchUtility(), | |
47 _CreateFileSystem) | |
48 self._avail_ds = self._avail_ds_factory.Create() | |
49 | |
50 def testGetApiAvailability(self): | |
51 self.assertEqual('stable', | |
52 self._avail_ds.GetApiAvailability('earlyAPI1').channel) | |
53 self.assertEqual('10', | |
54 self._avail_ds.GetApiAvailability('earlyAPI1').version) | |
55 self.assertEqual('trunk', | |
56 self._avail_ds.GetApiAvailability('earlyAPI2').channel) | |
57 self.assertEqual(None, | |
58 self._avail_ds.GetApiAvailability('earlyAPI2').version) | |
59 self.assertEquals('stable', | |
60 self._avail_ds.GetApiAvailability('tabs').channel) | |
61 self.assertEquals(18, | |
62 self._avail_ds.GetApiAvailability('tabs').version) | |
63 self.assertEquals('stable', | |
64 self._avail_ds.GetApiAvailability('bookmarks').channel) | |
65 self.assertEquals(21, | |
66 self._avail_ds.GetApiAvailability('bookmarks').version) | |
67 self.assertEquals('stable', | |
68 self._avail_ds.GetApiAvailability('windows').channel) | |
69 self.assertEquals(23, | |
70 self._avail_ds.GetApiAvailability('windows').version) | |
71 self.assertEquals('beta', | |
72 self._avail_ds.GetApiAvailability('storage').channel) | |
73 self.assertEquals(27, | |
74 self._avail_ds.GetApiAvailability('storage').version) | |
75 self.assertEquals('stable', | |
76 self._avail_ds.GetApiAvailability('alarms').channel) | |
77 self.assertEquals(24, | |
78 self._avail_ds.GetApiAvailability('alarms').version) | |
79 self.assertEquals('dev', | |
80 self._avail_ds.GetApiAvailability('sync').channel) | |
81 self.assertEquals(28, | |
82 self._avail_ds.GetApiAvailability('sync').version) | |
83 self.assertEquals('dev', | |
84 self._avail_ds.GetApiAvailability('cookies').channel) | |
85 self.assertEquals(28, | |
86 self._avail_ds.GetApiAvailability('cookies').version) | |
87 self.assertEquals('trunk', | |
88 self._avail_ds.GetApiAvailability('notReallyBetaAPI').channel) | |
89 self.assertEquals('trunk', | |
90 self._avail_ds.GetApiAvailability('notReallyBetaAPI').version) | |
91 self.assertEquals('trunk', | |
92 self._avail_ds.GetApiAvailability('trunkAPI').channel) | |
93 self.assertEquals('trunk', | |
94 self._avail_ds.GetApiAvailability('trunkAPI').version) | |
95 self.assertEquals('stable', | |
96 self._avail_ds.GetApiAvailability('menus').channel) | |
97 self.assertEquals(6, | |
98 self._avail_ds.GetApiAvailability('menus').version) | |
99 self.assertEquals('stable', | |
100 self._avail_ds.GetApiAvailability('idle').channel) | |
101 self.assertEquals(5, | |
102 self._avail_ds.GetApiAvailability('idle').version) | |
103 | |
104 if __name__ == '__main__': | |
105 unittest.main() | |
OLD | NEW |