Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/common/extensions/docs/server2/availability_finder_test.py

Issue 17397010: Adding AvailabilityFinder to Doc Server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 unittest
7
8 from availability_finder import AvailabilityFinder
9 from branch_utility import BranchUtility
10 from compiled_file_system import CompiledFileSystem
11 from fake_fetchers import ConfigureFakeFetchers
12 from object_store_creator import ObjectStoreCreator
13 from test_file_system import TestFileSystem
14 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES)
15
16 def _CreateCannedFileSystem(version):
17 branch = CANNED_BRANCHES[version]
18 return TestFileSystem(CANNED_API_FILE_SYSTEM_DATA[str(branch)])
19
20 class AvailabilityFinderTest(unittest.TestCase):
21 def setUp(self):
22 # Calls to BranchUtility will result in fetching fake data from test_data/.
23 ConfigureFakeFetchers()
not at google - send to devlin 2013/06/20 16:15:20 I know I keep on banging on about this, but unit t
epeterson 2013/06/21 00:48:26 Done.
24 self._avail_ds_factory = AvailabilityFinder.Factory(
25 ObjectStoreCreator.ForTest(),
26 CompiledFileSystem.Factory(
27 TestFileSystem(CANNED_API_FILE_SYSTEM_DATA['trunk']),
28 ObjectStoreCreator.ForTest()),
29 BranchUtility.Create(ObjectStoreCreator.ForTest()),
30 _CreateCannedFileSystem)
31 self._avail_ds = self._avail_ds_factory.Create()
32
33 def testGetApiAvailability(self):
34 # Key: Using 'channel' (i.e. 'beta') to represent an availability listing
35 # for an API in a _features.json file, and using |channel| (i.e. |dev|) to
36 # represent the development channel, or phase of development, where an API's
37 # availability is being checked.
38
39 # Testing the predetermined APIs found in
40 # templates/json/api_availabilities.json.
41 self.assertEqual('stable',
42 self._avail_ds.GetApiAvailability('jsonAPI1').channel)
43 self.assertEqual(10,
44 self._avail_ds.GetApiAvailability('jsonAPI1').version)
45 self.assertEqual('trunk',
46 self._avail_ds.GetApiAvailability('jsonAPI2').channel)
47 self.assertEqual(None,
48 self._avail_ds.GetApiAvailability('jsonAPI2').version)
49 self.assertEqual('dev',
50 self._avail_ds.GetApiAvailability('jsonAPI3').channel)
51 self.assertEqual(None,
52 self._avail_ds.GetApiAvailability('jsonAPI3').version)
53
54 # Testing APIs found only by checking file system existence.
55 self.assertEquals('stable',
56 self._avail_ds.GetApiAvailability('windows').channel)
57 self.assertEquals(23,
58 self._avail_ds.GetApiAvailability('windows').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('input.ime').channel)
65 self.assertEquals(18,
66 self._avail_ds.GetApiAvailability('input.ime').version)
67
68 # Testing API channel existence for _api_features.json.
69 # Listed as 'dev' on |beta|, 'dev' on |dev|.
70 self.assertEquals('dev',
71 self._avail_ds.GetApiAvailability('systemInfo.stuff').channel)
72 self.assertEquals(28,
73 self._avail_ds.GetApiAvailability('systemInfo.stuff').version)
74 # Listed as 'stable' on |beta|.
75 self.assertEquals('beta',
76 self._avail_ds.GetApiAvailability('systemInfo.cpu').channel)
77 self.assertEquals(27,
78 self._avail_ds.GetApiAvailability('systemInfo.cpu').version)
79
80 # Testing API channel existence for _manifest_features.json.
81 # Listed as 'trunk' on all channels.
82 self.assertEquals('trunk',
83 self._avail_ds.GetApiAvailability('sync').channel)
84 self.assertEquals('trunk',
85 self._avail_ds.GetApiAvailability('sync').version)
86 # No records of API until |trunk|.
87 self.assertEquals('trunk',
88 self._avail_ds.GetApiAvailability('history').channel)
89 self.assertEquals('trunk',
90 self._avail_ds.GetApiAvailability('history').version)
91 # Listed as 'dev' on |dev|.
92 self.assertEquals('dev',
93 self._avail_ds.GetApiAvailability('storage').channel)
94 self.assertEquals(28,
95 self._avail_ds.GetApiAvailability('storage').version)
96 # Stable in _manifest_features and into pre-18 versions.
97 self.assertEquals('stable',
98 self._avail_ds.GetApiAvailability('pageAction').channel)
99 self.assertEquals(8,
100 self._avail_ds.GetApiAvailability('pageAction').version)
101
102 # Testing API channel existence for _permission_features.json.
103 # Listed as 'beta' on |trunk|.
104 self.assertEquals('trunk',
105 self._avail_ds.GetApiAvailability('falseBetaAPI').version)
106 self.assertEquals('trunk',
107 self._avail_ds.GetApiAvailability('falseBetaAPI').version)
108 # Listed as 'trunk' on |trunk|.
109 self.assertEquals('trunk',
110 self._avail_ds.GetApiAvailability('trunkAPI').channel)
111 self.assertEquals('trunk',
112 self._avail_ds.GetApiAvailability('trunkAPI').version)
113 # Listed as 'trunk' on all development channels.
114 self.assertEquals('trunk',
115 self._avail_ds.GetApiAvailability('declarativeContent').channel)
116 self.assertEquals('trunk',
117 self._avail_ds.GetApiAvailability('declarativeContent').version)
118 # Listed as 'dev' on all development channels.
119 self.assertEquals('dev',
120 self._avail_ds.GetApiAvailability('bluetooth').channel)
121 self.assertEquals(28,
122 self._avail_ds.GetApiAvailability('bluetooth').version)
123 # Listed as 'dev' on |dev|.
124 self.assertEquals('dev',
125 self._avail_ds.GetApiAvailability('cookies').channel)
126 self.assertEquals(28,
127 self._avail_ds.GetApiAvailability('cookies').version)
128 # Treated as 'stable' APIs.
129 self.assertEquals('stable',
130 self._avail_ds.GetApiAvailability('alarms').channel)
131 self.assertEquals(24,
132 self._avail_ds.GetApiAvailability('alarms').version)
133 self.assertEquals('stable',
134 self._avail_ds.GetApiAvailability('bookmarks').channel)
135 self.assertEquals(21,
136 self._avail_ds.GetApiAvailability('bookmarks').version)
137
138 # Testing older API existence using extension_api.json.
139 self.assertEquals('stable',
140 self._avail_ds.GetApiAvailability('menus').channel)
141 self.assertEquals(6,
142 self._avail_ds.GetApiAvailability('menus').version)
143 self.assertEquals('stable',
144 self._avail_ds.GetApiAvailability('idle').channel)
145 self.assertEquals(5,
146 self._avail_ds.GetApiAvailability('idle').version)
147
148 # Switches between _features.json files across branches.
149 # Listed as 'trunk' on all channels.
150 self.assertEquals('trunk',
151 self._avail_ds.GetApiAvailability('contextMenus').channel)
152 self.assertEquals('trunk',
153 self._avail_ds.GetApiAvailability('contextMenus').version)
154 self.assertEquals('stable',
155 self._avail_ds.GetApiAvailability('systemInfo.display').channel)
156 self.assertEquals(23,
157 self._avail_ds.GetApiAvailability('systemInfo.display').version)
158 self.assertEquals('stable',
159 self._avail_ds.GetApiAvailability('webRequest').channel)
160 self.assertEquals(17,
161 self._avail_ds.GetApiAvailability('webRequest').version)
162
163 # Mid-upgrade cases:
164 # Listed as 'dev' on |beta| and 'beta' on |dev|.
165 self.assertEquals('dev',
166 self._avail_ds.GetApiAvailability('notifications').channel)
167 self.assertEquals(28,
168 self._avail_ds.GetApiAvailability('notifications').version)
169 # Listed as 'beta' on |stable|, 'dev' on |beta| ... until |stable| on trunk.
170 self.assertEquals('trunk',
171 self._avail_ds.GetApiAvailability('events').channel)
172 self.assertEquals('trunk',
173 self._avail_ds.GetApiAvailability('events').version)
not at google - send to devlin 2013/06/20 16:15:20 awesome tests!
174
175 if __name__ == '__main__':
176 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698