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

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

Issue 255473003: docserver: Adds "API scheduled for Chrome version..." text to dev and beta APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds style changes and rebase Created 6 years, 7 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 import os 5 import os
6 import sys 6 import sys
7 import unittest 7 import unittest
8 8
9 import api_schema_graph 9 import api_schema_graph
10 from availability_finder import AvailabilityFinder 10 from availability_finder import AvailabilityFinder, AvailabilityInfo
11 from branch_utility import BranchUtility, ChannelInfo 11 from branch_utility import BranchUtility, ChannelInfo
12 from compiled_file_system import CompiledFileSystem 12 from compiled_file_system import CompiledFileSystem
13 from fake_host_file_system_provider import FakeHostFileSystemProvider 13 from fake_host_file_system_provider import FakeHostFileSystemProvider
14 from fake_url_fetcher import FakeUrlFetcher 14 from fake_url_fetcher import FakeUrlFetcher
15 from host_file_system_iterator import HostFileSystemIterator 15 from host_file_system_iterator import HostFileSystemIterator
16 from mock_function import MockFunction 16 from mock_function import MockFunction
17 from object_store_creator import ObjectStoreCreator 17 from object_store_creator import ObjectStoreCreator
18 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES) 18 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES)
19 from test_data.object_level_availability.tabs import TABS_SCHEMA_BRANCHES 19 from test_data.object_level_availability.tabs import TABS_SCHEMA_BRANCHES
20 from test_util import Server2Path 20 from test_util import Server2Path
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 api_schema_graph.APISchemaGraph = original_constructor 90 api_schema_graph.APISchemaGraph = original_constructor
91 91
92 def testGetApiAvailability(self): 92 def testGetApiAvailability(self):
93 # Key: Using 'channel' (i.e. 'beta') to represent an availability listing 93 # Key: Using 'channel' (i.e. 'beta') to represent an availability listing
94 # for an API in a _features.json file, and using |channel| (i.e. |dev|) to 94 # for an API in a _features.json file, and using |channel| (i.e. |dev|) to
95 # represent the development channel, or phase of development, where an API's 95 # represent the development channel, or phase of development, where an API's
96 # availability is being checked. 96 # availability is being checked.
97 97
98 # Testing APIs with predetermined availability. 98 # Testing APIs with predetermined availability.
99 self.assertEqual( 99 self.assertEqual(
100 ChannelInfo('trunk', 'trunk', 'trunk'), 100 AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
101 self._avail_finder.GetApiAvailability('jsonTrunkAPI')) 101 self._avail_finder.GetApiAvailability('jsonTrunkAPI'))
102 self.assertEqual( 102 self.assertEqual(
103 ChannelInfo('dev', CANNED_BRANCHES[28], 28), 103 AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
104 self._avail_finder.GetApiAvailability('jsonDevAPI')) 104 self._avail_finder.GetApiAvailability('jsonDevAPI'))
105 self.assertEqual( 105 self.assertEqual(
106 ChannelInfo('beta', CANNED_BRANCHES[27], 27), 106 AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27)),
107 self._avail_finder.GetApiAvailability('jsonBetaAPI')) 107 self._avail_finder.GetApiAvailability('jsonBetaAPI'))
108 self.assertEqual( 108 self.assertEqual(
109 ChannelInfo('stable', CANNED_BRANCHES[20], 20), 109 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[20], 20)),
110 self._avail_finder.GetApiAvailability('jsonStableAPI')) 110 self._avail_finder.GetApiAvailability('jsonStableAPI'))
111 111
112 # Testing a whitelisted API. 112 # Testing a whitelisted API.
113 self.assertEquals( 113 self.assertEquals(
114 ChannelInfo('beta', CANNED_BRANCHES[27], 27), 114 AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27)),
115 self._avail_finder.GetApiAvailability('declarativeWebRequest')) 115 self._avail_finder.GetApiAvailability('declarativeWebRequest'))
116 116
117 # Testing APIs found only by checking file system existence. 117 # Testing APIs found only by checking file system existence.
118 self.assertEquals( 118 self.assertEquals(
119 ChannelInfo('stable', CANNED_BRANCHES[23], 23), 119 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[23], 23)),
120 self._avail_finder.GetApiAvailability('windows')) 120 self._avail_finder.GetApiAvailability('windows'))
121 self.assertEquals( 121 self.assertEquals(
122 ChannelInfo('stable', CANNED_BRANCHES[18], 18), 122 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[18], 18)),
123 self._avail_finder.GetApiAvailability('tabs')) 123 self._avail_finder.GetApiAvailability('tabs'))
124 self.assertEquals( 124 self.assertEquals(
125 ChannelInfo('stable', CANNED_BRANCHES[18], 18), 125 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[18], 18)),
126 self._avail_finder.GetApiAvailability('input.ime')) 126 self._avail_finder.GetApiAvailability('input.ime'))
127 127
128 # Testing API channel existence for _api_features.json. 128 # Testing API channel existence for _api_features.json.
129 # Listed as 'dev' on |beta|, 'dev' on |dev|. 129 # Listed as 'dev' on |beta|, 'dev' on |dev|.
130 self.assertEquals( 130 self.assertEquals(
131 ChannelInfo('dev', CANNED_BRANCHES[28], 28), 131 AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
132 self._avail_finder.GetApiAvailability('systemInfo.stuff')) 132 self._avail_finder.GetApiAvailability('systemInfo.stuff'))
133 # Listed as 'stable' on |beta|. 133 # Listed as 'stable' on |beta|.
134 self.assertEquals( 134 self.assertEquals(
135 AvailabilityInfo(
135 ChannelInfo('beta', CANNED_BRANCHES[27], 27), 136 ChannelInfo('beta', CANNED_BRANCHES[27], 27),
137 scheduled=28),
136 self._avail_finder.GetApiAvailability('systemInfo.cpu')) 138 self._avail_finder.GetApiAvailability('systemInfo.cpu'))
137 139
138 # Testing API channel existence for _manifest_features.json. 140 # Testing API channel existence for _manifest_features.json.
139 # Listed as 'trunk' on all channels. 141 # Listed as 'trunk' on all channels.
140 self.assertEquals( 142 self.assertEquals(
141 ChannelInfo('trunk', 'trunk', 'trunk'), 143 AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
142 self._avail_finder.GetApiAvailability('sync')) 144 self._avail_finder.GetApiAvailability('sync'))
143 # No records of API until |trunk|. 145 # No records of API until |trunk|.
144 self.assertEquals( 146 self.assertEquals(
145 ChannelInfo('trunk', 'trunk', 'trunk'), 147 AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
146 self._avail_finder.GetApiAvailability('history')) 148 self._avail_finder.GetApiAvailability('history'))
147 # Listed as 'dev' on |dev|. 149 # Listed as 'dev' on |dev|.
148 self.assertEquals( 150 self.assertEquals(
149 ChannelInfo('dev', CANNED_BRANCHES[28], 28), 151 AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
150 self._avail_finder.GetApiAvailability('storage')) 152 self._avail_finder.GetApiAvailability('storage'))
151 # Stable in _manifest_features and into pre-18 versions. 153 # Stable in _manifest_features and into pre-18 versions.
152 self.assertEquals( 154 self.assertEquals(
153 ChannelInfo('stable', CANNED_BRANCHES[8], 8), 155 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[8], 8)),
154 self._avail_finder.GetApiAvailability('pageAction')) 156 self._avail_finder.GetApiAvailability('pageAction'))
155 157
156 # Testing API channel existence for _permission_features.json. 158 # Testing API channel existence for _permission_features.json.
157 # Listed as 'beta' on |trunk|. 159 # Listed as 'beta' on |trunk|.
158 self.assertEquals( 160 self.assertEquals(
159 ChannelInfo('trunk', 'trunk', 'trunk'), 161 AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
160 self._avail_finder.GetApiAvailability('falseBetaAPI')) 162 self._avail_finder.GetApiAvailability('falseBetaAPI'))
161 # Listed as 'trunk' on |trunk|. 163 # Listed as 'trunk' on |trunk|.
162 self.assertEquals( 164 self.assertEquals(
163 ChannelInfo('trunk', 'trunk', 'trunk'), 165 AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
164 self._avail_finder.GetApiAvailability('trunkAPI')) 166 self._avail_finder.GetApiAvailability('trunkAPI'))
165 # Listed as 'trunk' on all development channels. 167 # Listed as 'trunk' on all development channels.
166 self.assertEquals( 168 self.assertEquals(
167 ChannelInfo('trunk', 'trunk', 'trunk'), 169 AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
168 self._avail_finder.GetApiAvailability('declarativeContent')) 170 self._avail_finder.GetApiAvailability('declarativeContent'))
169 # Listed as 'dev' on all development channels. 171 # Listed as 'dev' on all development channels.
170 self.assertEquals( 172 self.assertEquals(
171 ChannelInfo('dev', CANNED_BRANCHES[28], 28), 173 AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
172 self._avail_finder.GetApiAvailability('bluetooth')) 174 self._avail_finder.GetApiAvailability('bluetooth'))
173 # Listed as 'dev' on |dev|. 175 # Listed as 'dev' on |dev|.
174 self.assertEquals( 176 self.assertEquals(
175 ChannelInfo('dev', CANNED_BRANCHES[28], 28), 177 AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
176 self._avail_finder.GetApiAvailability('cookies')) 178 self._avail_finder.GetApiAvailability('cookies'))
177 # Treated as 'stable' APIs. 179 # Treated as 'stable' APIs.
178 self.assertEquals( 180 self.assertEquals(
179 ChannelInfo('stable', CANNED_BRANCHES[24], 24), 181 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[24], 24)),
180 self._avail_finder.GetApiAvailability('alarms')) 182 self._avail_finder.GetApiAvailability('alarms'))
181 self.assertEquals( 183 self.assertEquals(
182 ChannelInfo('stable', CANNED_BRANCHES[21], 21), 184 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[21], 21)),
183 self._avail_finder.GetApiAvailability('bookmarks')) 185 self._avail_finder.GetApiAvailability('bookmarks'))
184 186
185 # Testing older API existence using extension_api.json. 187 # Testing older API existence using extension_api.json.
186 self.assertEquals( 188 self.assertEquals(
187 ChannelInfo('stable', CANNED_BRANCHES[6], 6), 189 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[6], 6)),
188 self._avail_finder.GetApiAvailability('menus')) 190 self._avail_finder.GetApiAvailability('menus'))
189 self.assertEquals( 191 self.assertEquals(
190 ChannelInfo('stable', CANNED_BRANCHES[5], 5), 192 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[5], 5)),
191 self._avail_finder.GetApiAvailability('idle')) 193 self._avail_finder.GetApiAvailability('idle'))
192 194
193 # Switches between _features.json files across branches. 195 # Switches between _features.json files across branches.
194 # Listed as 'trunk' on all channels, in _api, _permission, or _manifest. 196 # Listed as 'trunk' on all channels, in _api, _permission, or _manifest.
195 self.assertEquals( 197 self.assertEquals(
196 ChannelInfo('trunk', 'trunk', 'trunk'), 198 AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
197 self._avail_finder.GetApiAvailability('contextMenus')) 199 self._avail_finder.GetApiAvailability('contextMenus'))
198 # Moves between _permission and _manifest as file system is traversed. 200 # Moves between _permission and _manifest as file system is traversed.
199 self.assertEquals( 201 self.assertEquals(
200 ChannelInfo('stable', CANNED_BRANCHES[23], 23), 202 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[23], 23)),
201 self._avail_finder.GetApiAvailability('systemInfo.display')) 203 self._avail_finder.GetApiAvailability('systemInfo.display'))
202 self.assertEquals( 204 self.assertEquals(
203 ChannelInfo('stable', CANNED_BRANCHES[17], 17), 205 AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[17], 17)),
204 self._avail_finder.GetApiAvailability('webRequest')) 206 self._avail_finder.GetApiAvailability('webRequest'))
205 207
206 # Mid-upgrade cases: 208 # Mid-upgrade cases:
207 # Listed as 'dev' on |beta| and 'beta' on |dev|. 209 # Listed as 'dev' on |beta| and 'beta' on |dev|.
208 self.assertEquals( 210 self.assertEquals(
209 ChannelInfo('dev', CANNED_BRANCHES[28], 28), 211 AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
210 self._avail_finder.GetApiAvailability('notifications')) 212 self._avail_finder.GetApiAvailability('notifications'))
211 # Listed as 'beta' on |stable|, 'dev' on |beta| ... until |stable| on trunk. 213 # Listed as 'beta' on |stable|, 'dev' on |beta| ... until |stable| on trunk.
212 self.assertEquals( 214 self.assertEquals(
213 ChannelInfo('trunk', 'trunk', 'trunk'), 215 AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
214 self._avail_finder.GetApiAvailability('events')) 216 self._avail_finder.GetApiAvailability('events'))
215 217
216 def testGetApiNodeAvailability(self): 218 def testGetApiNodeAvailability(self):
217 # Allow the LookupResult constructions below to take just one line. 219 # Allow the LookupResult constructions below to take just one line.
218 lookup_result = api_schema_graph.LookupResult 220 lookup_result = api_schema_graph.LookupResult
219 availability_graph = self._node_avail_finder.GetApiNodeAvailability('tabs') 221 availability_graph = self._node_avail_finder.GetApiNodeAvailability('tabs')
220 222
221 self.assertEquals( 223 self.assertEquals(
222 lookup_result(True, self._branch_utility.GetChannelInfo('trunk')), 224 lookup_result(True, self._branch_utility.GetChannelInfo('trunk')),
223 availability_graph.Lookup('tabs', 'properties', 225 availability_graph.Lookup('tabs', 'properties',
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 self.assertEqual(lookup_result(False, None), 315 self.assertEqual(lookup_result(False, None),
314 availability_graph.Lookup('functions')) 316 availability_graph.Lookup('functions'))
315 self.assertEqual(lookup_result(False, None), 317 self.assertEqual(lookup_result(False, None),
316 availability_graph.Lookup('events', 'onActivated', 318 availability_graph.Lookup('events', 'onActivated',
317 'parameters', 'activeInfo', 319 'parameters', 'activeInfo',
318 'tabId')) 320 'tabId'))
319 321
320 322
321 if __name__ == '__main__': 323 if __name__ == '__main__':
322 unittest.main() 324 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/availability_finder.py ('k') | chrome/common/extensions/docs/server2/cron.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698