Docserver: Replace instances of 'Api' with 'API'

The 'API' spelling variant is favored over the 'Api' spelling in current docserver
code, so to maintain consistency the 'API' spelling has been enforced.

NOTRY=True

Review URL: https://codereview.chromium.org/337373004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278449 0039d316-1c4b-4281-b951-d872f2087c98
parent 8e44a5b0
...@@ -115,12 +115,12 @@ class _JSCModel(object): ...@@ -115,12 +115,12 @@ class _JSCModel(object):
as_dict['byName'] = _GetByNameDict(as_dict) as_dict['byName'] = _GetByNameDict(as_dict)
return as_dict return as_dict
def _GetApiAvailability(self): def _GetAPIAvailability(self):
return self._availability_finder.GetApiAvailability(self._namespace.name) return self._availability_finder.GetAPIAvailability(self._namespace.name)
def _GetChannelWarning(self): def _GetChannelWarning(self):
if not self._IsExperimental(): if not self._IsExperimental():
return { self._GetApiAvailability().channel_info.channel: True } return { self._GetAPIAvailability().channel_info.channel: True }
return None return None
def _IsExperimental(self): def _IsExperimental(self):
...@@ -354,7 +354,7 @@ class _JSCModel(object): ...@@ -354,7 +354,7 @@ class _JSCModel(object):
version = None version = None
scheduled = None scheduled = None
else: else:
availability = self._GetApiAvailability() availability = self._GetAPIAvailability()
status = availability.channel_info.channel status = availability.channel_info.channel
version = availability.channel_info.version version = availability.channel_info.version
scheduled = availability.scheduled scheduled = availability.scheduled
......
...@@ -39,13 +39,13 @@ def _GetType(dict_, name): ...@@ -39,13 +39,13 @@ def _GetType(dict_, name):
class _FakeAvailabilityFinder(object): class _FakeAvailabilityFinder(object):
def GetApiAvailability(self, version): def GetAPIAvailability(self, version):
return AvailabilityInfo(ChannelInfo('stable', '396', 5)) return AvailabilityInfo(ChannelInfo('stable', '396', 5))
class _FakeScheduledAvailabilityFinder(object): class _FakeScheduledAvailabilityFinder(object):
def GetApiAvailability(self, version): def GetAPIAvailability(self, version):
return AvailabilityInfo(ChannelInfo('beta', '1453', 27), scheduled=28) return AvailabilityInfo(ChannelInfo('beta', '1453', 27), scheduled=28)
...@@ -69,7 +69,7 @@ class APIDataSourceTest(unittest.TestCase): ...@@ -69,7 +69,7 @@ class APIDataSourceTest(unittest.TestCase):
server_instance.object_store_creator) server_instance.object_store_creator)
self._api_models = server_instance.api_models self._api_models = server_instance.api_models
# Used for testGetApiAvailability() so that valid-ish data is processed. # Used for testGetAPIAvailability() so that valid-ish data is processed.
server_instance = ServerInstance.ForTest( server_instance = ServerInstance.ForTest(
file_system_provider=FakeHostFileSystemProvider( file_system_provider=FakeHostFileSystemProvider(
CANNED_API_FILE_SYSTEM_DATA)) CANNED_API_FILE_SYSTEM_DATA))
...@@ -114,7 +114,7 @@ class APIDataSourceTest(unittest.TestCase): ...@@ -114,7 +114,7 @@ class APIDataSourceTest(unittest.TestCase):
self.assertEquals('67', _FormatValue(67)) self.assertEquals('67', _FormatValue(67))
self.assertEquals('234,567', _FormatValue(234567)) self.assertEquals('234,567', _FormatValue(234567))
def testGetApiAvailability(self): def testGetAPIAvailability(self):
api_availabilities = { api_availabilities = {
'bluetooth': AvailabilityInfo( 'bluetooth': AvailabilityInfo(
ChannelInfo('dev', CANNED_BRANCHES[28], 28)), ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
...@@ -136,7 +136,7 @@ class APIDataSourceTest(unittest.TestCase): ...@@ -136,7 +136,7 @@ class APIDataSourceTest(unittest.TestCase):
_FakeTemplateCache(), _FakeTemplateCache(),
self._features_bundle, self._features_bundle,
None) None)
self.assertEquals(availability, model._GetApiAvailability()) self.assertEquals(availability, model._GetAPIAvailability())
def testGetIntroList(self): def testGetIntroList(self):
model = _JSCModel(self._api_models.GetModel('tester').Get(), model = _JSCModel(self._api_models.GetModel('tester').Get(),
......
...@@ -36,7 +36,7 @@ class APIListDataSource(DataSource): ...@@ -36,7 +36,7 @@ class APIListDataSource(DataSource):
def _GenerateAPIDict(self): def _GenerateAPIDict(self):
def get_channel_info(api_name): def get_channel_info(api_name):
return self._availability_finder.GetApiAvailability(api_name).channel_info return self._availability_finder.GetAPIAvailability(api_name).channel_info
def get_api_platform(api_name): def get_api_platform(api_name):
feature = self._features_bundle.GetAPIFeatures().Get()[api_name] feature = self._features_bundle.GetAPIFeatures().Get()[api_name]
......
...@@ -33,13 +33,13 @@ def _ToTestFeatures(names): ...@@ -33,13 +33,13 @@ def _ToTestFeatures(names):
return features return features
def _ToTestApiData(names): def _ToTestAPIData(names):
api_data = dict((name, [{'namespace': name, 'description': description}]) api_data = dict((name, [{'namespace': name, 'description': description}])
for name, description in names) for name, description in names)
return api_data return api_data
def _ToTestApiSchema(names, apis): def _ToTestAPISchema(names, apis):
for name, json_file in names: for name, json_file in names:
apis['api'][json_file] = json.dumps(_TEST_API_DATA[name]) apis['api'][json_file] = json.dumps(_TEST_API_DATA[name])
return apis return apis
...@@ -60,7 +60,7 @@ _TEST_API_FEATURES = _ToTestFeatures([ ...@@ -60,7 +60,7 @@ _TEST_API_FEATURES = _ToTestFeatures([
]) ])
_TEST_API_DATA = _ToTestApiData([ _TEST_API_DATA = _ToTestAPIData([
('alarms', u'<code>alarms</code>'), ('alarms', u'<code>alarms</code>'),
('app.window', u'<code>app.window</code>'), ('app.window', u'<code>app.window</code>'),
('browserAction', u'<code>browserAction</code>'), ('browserAction', u'<code>browserAction</code>'),
...@@ -90,7 +90,7 @@ _TEST_API_SCHEMA = [ ...@@ -90,7 +90,7 @@ _TEST_API_SCHEMA = [
] ]
_TEST_DATA = _ToTestApiSchema(_TEST_API_SCHEMA, { _TEST_DATA = _ToTestAPISchema(_TEST_API_SCHEMA, {
'api': { 'api': {
'_api_features.json': json.dumps(_TEST_API_FEATURES), '_api_features.json': json.dumps(_TEST_API_FEATURES),
'_manifest_features.json': '{}', '_manifest_features.json': '{}',
......
...@@ -56,7 +56,7 @@ API_SCHEMA = [{ ...@@ -56,7 +56,7 @@ API_SCHEMA = [{
class APISchemaGraphTest(unittest.TestCase): class APISchemaGraphTest(unittest.TestCase):
def testLookup(self): def testLookup(self):
self._testApiSchema(APISchemaGraph(API_SCHEMA)) self._testAPISchema(APISchemaGraph(API_SCHEMA))
def testIsEmpty(self): def testIsEmpty(self):
# A few assertions to make sure that Lookup works on empty sets. # A few assertions to make sure that Lookup works on empty sets.
...@@ -79,10 +79,10 @@ class APISchemaGraphTest(unittest.TestCase): ...@@ -79,10 +79,10 @@ class APISchemaGraphTest(unittest.TestCase):
'parameters', 'updateInfo')) 'parameters', 'updateInfo'))
def testSubtractEmpty(self): def testSubtractEmpty(self):
self._testApiSchema( self._testAPISchema(
APISchemaGraph(API_SCHEMA).Subtract(APISchemaGraph({}))) APISchemaGraph(API_SCHEMA).Subtract(APISchemaGraph({})))
def _testApiSchema(self, api_schema_graph): def _testAPISchema(self, api_schema_graph):
self.assertEqual(LookupResult(True, None), self.assertEqual(LookupResult(True, None),
api_schema_graph.Lookup('tabs', 'properties', api_schema_graph.Lookup('tabs', 'properties',
'TAB_PROPERTY_ONE')) 'TAB_PROPERTY_ONE'))
......
...@@ -96,7 +96,7 @@ class AvailabilityFinder(object): ...@@ -96,7 +96,7 @@ class AvailabilityFinder(object):
return AvailabilityInfo( return AvailabilityInfo(
self._branch_utility.GetChannelInfo(api_info['channel'])) self._branch_utility.GetChannelInfo(api_info['channel']))
def _GetApiSchemaFilename(self, api_name, file_system, version): def _GetAPISchemaFilename(self, api_name, file_system, version):
'''Gets the name of the file which may contain the schema for |api_name| in '''Gets the name of the file which may contain the schema for |api_name| in
|file_system|, or None if the API is not found. Note that this may be the |file_system|, or None if the API is not found. Note that this may be the
single _EXTENSION_API file which all APIs share in older versions of Chrome, single _EXTENSION_API file which all APIs share in older versions of Chrome,
...@@ -119,16 +119,16 @@ class AvailabilityFinder(object): ...@@ -119,16 +119,16 @@ class AvailabilityFinder(object):
pass pass
return None return None
def _GetApiSchema(self, api_name, file_system, version): def _GetAPISchema(self, api_name, file_system, version):
'''Searches |file_system| for |api_name|'s API schema data, and processes '''Searches |file_system| for |api_name|'s API schema data, and processes
and returns it if found. and returns it if found.
''' '''
api_filename = self._GetApiSchemaFilename(api_name, file_system, version) api_filename = self._GetAPISchemaFilename(api_name, file_system, version)
if api_filename is None: if api_filename is None:
# No file for the API could be found in the given |file_system|. # No file for the API could be found in the given |file_system|.
return None return None
schema_fs = self._compiled_fs_factory.ForApiSchema(file_system) schema_fs = self._compiled_fs_factory.ForAPISchema(file_system)
api_schemas = schema_fs.GetFromFile(api_filename).Get() api_schemas = schema_fs.GetFromFile(api_filename).Get()
matching_schemas = [api for api in api_schemas matching_schemas = [api for api in api_schemas
if api['namespace'] == api_name] if api['namespace'] == api_name]
...@@ -137,15 +137,15 @@ class AvailabilityFinder(object): ...@@ -137,15 +137,15 @@ class AvailabilityFinder(object):
assert len(matching_schemas) <= 1 assert len(matching_schemas) <= 1
return matching_schemas or None return matching_schemas or None
def _HasApiSchema(self, api_name, file_system, version): def _HasAPISchema(self, api_name, file_system, version):
'''Whether or not an API schema for |api_name|exists in the given '''Whether or not an API schema for |api_name|exists in the given
|file_system|. |file_system|.
''' '''
filename = self._GetApiSchemaFilename(api_name, file_system, version) filename = self._GetAPISchemaFilename(api_name, file_system, version)
if filename is None: if filename is None:
return False return False
if filename.endswith(_EXTENSION_API): if filename.endswith(_EXTENSION_API):
return self._GetApiSchema(api_name, file_system, version) is not None return self._GetAPISchema(api_name, file_system, version) is not None
return True return True
def _CheckStableAvailability(self, api_name, file_system, version): def _CheckStableAvailability(self, api_name, file_system, version):
...@@ -161,7 +161,7 @@ class AvailabilityFinder(object): ...@@ -161,7 +161,7 @@ class AvailabilityFinder(object):
if version >= _API_FEATURES_MIN_VERSION: if version >= _API_FEATURES_MIN_VERSION:
# The _api_features.json file first appears in version 28 and should be # The _api_features.json file first appears in version 28 and should be
# the most reliable for finding API availability. # the most reliable for finding API availability.
available_channel = self._GetChannelFromApiFeatures(api_name, available_channel = self._GetChannelFromAPIFeatures(api_name,
features_bundle) features_bundle)
if version >= _ORIGINAL_FEATURES_MIN_VERSION: if version >= _ORIGINAL_FEATURES_MIN_VERSION:
# The _permission_features.json and _manifest_features.json files are # The _permission_features.json and _manifest_features.json files are
...@@ -177,7 +177,7 @@ class AvailabilityFinder(object): ...@@ -177,7 +177,7 @@ class AvailabilityFinder(object):
# Fall back to a check for file system existence if the API is not # Fall back to a check for file system existence if the API is not
# stable in any of the _features.json files, or if the _features files # stable in any of the _features.json files, or if the _features files
# do not exist (version 19 and earlier). # do not exist (version 19 and earlier).
return self._HasApiSchema(api_name, file_system, version) return self._HasAPISchema(api_name, file_system, version)
def _CheckChannelAvailability(self, api_name, file_system, channel_info): def _CheckChannelAvailability(self, api_name, file_system, channel_info):
'''Searches through the _features files in a given |file_system|, falling '''Searches through the _features files in a given |file_system|, falling
...@@ -186,11 +186,11 @@ class AvailabilityFinder(object): ...@@ -186,11 +186,11 @@ class AvailabilityFinder(object):
''' '''
features_bundle = self._CreateFeaturesBundle(file_system) features_bundle = self._CreateFeaturesBundle(file_system)
available_channel = ( available_channel = (
self._GetChannelFromApiFeatures(api_name, features_bundle) or self._GetChannelFromAPIFeatures(api_name, features_bundle) or
self._GetChannelFromPermissionFeatures(api_name, features_bundle) or self._GetChannelFromPermissionFeatures(api_name, features_bundle) or
self._GetChannelFromManifestFeatures(api_name, features_bundle)) self._GetChannelFromManifestFeatures(api_name, features_bundle))
if (available_channel is None and if (available_channel is None and
self._HasApiSchema(api_name, file_system, channel_info.version)): self._HasAPISchema(api_name, file_system, channel_info.version)):
# If an API is not represented in any of the _features files, but exists # If an API is not represented in any of the _features files, but exists
# in the filesystem, then assume it is available in this version. # in the filesystem, then assume it is available in this version.
# The chrome.windows API is an example of this. # The chrome.windows API is an example of this.
...@@ -207,7 +207,7 @@ class AvailabilityFinder(object): ...@@ -207,7 +207,7 @@ class AvailabilityFinder(object):
self._compiled_fs_factory, self._compiled_fs_factory,
self._object_store_creator) self._object_store_creator)
def _GetChannelFromApiFeatures(self, api_name, features_bundle): def _GetChannelFromAPIFeatures(self, api_name, features_bundle):
return _GetChannelFromFeatures(api_name, features_bundle.GetAPIFeatures()) return _GetChannelFromFeatures(api_name, features_bundle.GetAPIFeatures())
def _GetChannelFromManifestFeatures(self, api_name, features_bundle): def _GetChannelFromManifestFeatures(self, api_name, features_bundle):
...@@ -220,7 +220,7 @@ class AvailabilityFinder(object): ...@@ -220,7 +220,7 @@ class AvailabilityFinder(object):
return _GetChannelFromFeatures(api_name, return _GetChannelFromFeatures(api_name,
features_bundle.GetPermissionFeatures()) features_bundle.GetPermissionFeatures())
def _CheckApiAvailability(self, api_name, file_system, channel_info): def _CheckAPIAvailability(self, api_name, file_system, channel_info):
'''Determines the availability for an API at a certain version of Chrome. '''Determines the availability for an API at a certain version of Chrome.
Two branches of logic are used depending on whether or not the API is Two branches of logic are used depending on whether or not the API is
determined to be 'stable' at the given version. determined to be 'stable' at the given version.
...@@ -235,7 +235,7 @@ class AvailabilityFinder(object): ...@@ -235,7 +235,7 @@ class AvailabilityFinder(object):
def _FindScheduled(self, api_name): def _FindScheduled(self, api_name):
'''Determines the earliest version of Chrome where the API is stable. '''Determines the earliest version of Chrome where the API is stable.
Unlike the code in GetApiAvailability, this checks if the API is stable Unlike the code in GetAPIAvailability, this checks if the API is stable
even when Chrome is in dev or beta, which shows that the API is scheduled even when Chrome is in dev or beta, which shows that the API is scheduled
to be stable in that verison of Chrome. to be stable in that verison of Chrome.
''' '''
...@@ -248,7 +248,7 @@ class AvailabilityFinder(object): ...@@ -248,7 +248,7 @@ class AvailabilityFinder(object):
return stable_channel.version if stable_channel else None return stable_channel.version if stable_channel else None
def GetApiAvailability(self, api_name): def GetAPIAvailability(self, api_name):
'''Performs a search for an API's top-level availability by using a '''Performs a search for an API's top-level availability by using a
HostFileSystemIterator instance to traverse multiple version of the HostFileSystemIterator instance to traverse multiple version of the
SVN filesystem. SVN filesystem.
...@@ -264,7 +264,7 @@ class AvailabilityFinder(object): ...@@ -264,7 +264,7 @@ class AvailabilityFinder(object):
return availability return availability
def check_api_availability(file_system, channel_info): def check_api_availability(file_system, channel_info):
return self._CheckApiAvailability(api_name, file_system, channel_info) return self._CheckAPIAvailability(api_name, file_system, channel_info)
channel_info = self._file_system_iterator.Descending( channel_info = self._file_system_iterator.Descending(
self._branch_utility.GetChannelInfo('dev'), self._branch_utility.GetChannelInfo('dev'),
...@@ -284,7 +284,7 @@ class AvailabilityFinder(object): ...@@ -284,7 +284,7 @@ class AvailabilityFinder(object):
self._top_level_object_store.Set(api_name, availability) self._top_level_object_store.Set(api_name, availability)
return availability return availability
def GetApiNodeAvailability(self, api_name): def GetAPINodeAvailability(self, api_name):
'''Returns an APISchemaGraph annotated with each node's availability (the '''Returns an APISchemaGraph annotated with each node's availability (the
ChannelInfo at the oldest channel it's available in). ChannelInfo at the oldest channel it's available in).
''' '''
...@@ -299,14 +299,14 @@ class AvailabilityFinder(object): ...@@ -299,14 +299,14 @@ class AvailabilityFinder(object):
availability_graph = APISchemaGraph() availability_graph = APISchemaGraph()
host_fs = self._host_file_system host_fs = self._host_file_system
trunk_stat = assert_not_none(host_fs.Stat(self._GetApiSchemaFilename( trunk_stat = assert_not_none(host_fs.Stat(self._GetAPISchemaFilename(
api_name, host_fs, 'trunk'))) api_name, host_fs, 'trunk')))
# Weird object thing here because nonlocal is Python 3. # Weird object thing here because nonlocal is Python 3.
previous = type('previous', (object,), {'stat': None, 'graph': None}) previous = type('previous', (object,), {'stat': None, 'graph': None})
def update_availability_graph(file_system, channel_info): def update_availability_graph(file_system, channel_info):
version_filename = assert_not_none(self._GetApiSchemaFilename( version_filename = assert_not_none(self._GetAPISchemaFilename(
api_name, file_system, channel_info.version)) api_name, file_system, channel_info.version))
version_stat = assert_not_none(file_system.Stat(version_filename)) version_stat = assert_not_none(file_system.Stat(version_filename))
...@@ -321,7 +321,7 @@ class AvailabilityFinder(object): ...@@ -321,7 +321,7 @@ class AvailabilityFinder(object):
# #
# Calling |availability_graph|.Lookup() on the nodes being updated # Calling |availability_graph|.Lookup() on the nodes being updated
# will return the |annotation| object -- the current |channel_info|. # will return the |annotation| object -- the current |channel_info|.
version_graph = APISchemaGraph(self._GetApiSchema( version_graph = APISchemaGraph(self._GetAPISchema(
api_name, file_system, channel_info.version)) api_name, file_system, channel_info.version))
availability_graph.Update(version_graph.Subtract(availability_graph), availability_graph.Update(version_graph.Subtract(availability_graph),
annotation=channel_info) annotation=channel_info)
...@@ -334,7 +334,7 @@ class AvailabilityFinder(object): ...@@ -334,7 +334,7 @@ class AvailabilityFinder(object):
return version_stat != trunk_stat return version_stat != trunk_stat
self._file_system_iterator.Ascending( self._file_system_iterator.Ascending(
self.GetApiAvailability(api_name).channel_info, self.GetAPIAvailability(api_name).channel_info,
update_availability_graph) update_availability_graph)
self._node_level_object_store.Set(api_name, availability_graph) self._node_level_object_store.Set(api_name, availability_graph)
......
...@@ -80,7 +80,7 @@ class AvailabilityFinderTest(unittest.TestCase): ...@@ -80,7 +80,7 @@ class AvailabilityFinderTest(unittest.TestCase):
num_graphs_created = num_versions - len(TABS_UNMODIFIED_VERSIONS) num_graphs_created = num_versions - len(TABS_UNMODIFIED_VERSIONS)
# Run the logic for object-level availability for an API. # Run the logic for object-level availability for an API.
self._node_avail_finder.GetApiNodeAvailability('tabs') self._node_avail_finder.GetAPINodeAvailability('tabs')
self.assertTrue(*api_schema_graph.APISchemaGraph.CheckAndReset( self.assertTrue(*api_schema_graph.APISchemaGraph.CheckAndReset(
num_graphs_created)) num_graphs_created))
...@@ -89,7 +89,7 @@ class AvailabilityFinderTest(unittest.TestCase): ...@@ -89,7 +89,7 @@ class AvailabilityFinderTest(unittest.TestCase):
# constructor. # constructor.
api_schema_graph.APISchemaGraph = original_constructor api_schema_graph.APISchemaGraph = original_constructor
def testGetApiAvailability(self): def testGetAPIAvailability(self):
# Key: Using 'channel' (i.e. 'beta') to represent an availability listing # Key: Using 'channel' (i.e. 'beta') to represent an availability listing
# for an API in a _features.json file, and using |channel| (i.e. |dev|) to # for an API in a _features.json file, and using |channel| (i.e. |dev|) to
# represent the development channel, or phase of development, where an API's # represent the development channel, or phase of development, where an API's
...@@ -98,127 +98,127 @@ class AvailabilityFinderTest(unittest.TestCase): ...@@ -98,127 +98,127 @@ class AvailabilityFinderTest(unittest.TestCase):
# Testing APIs with predetermined availability. # Testing APIs with predetermined availability.
self.assertEqual( self.assertEqual(
AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')), AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
self._avail_finder.GetApiAvailability('jsonTrunkAPI')) self._avail_finder.GetAPIAvailability('jsonTrunkAPI'))
self.assertEqual( self.assertEqual(
AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)), AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
self._avail_finder.GetApiAvailability('jsonDevAPI')) self._avail_finder.GetAPIAvailability('jsonDevAPI'))
self.assertEqual( self.assertEqual(
AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27)), AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27)),
self._avail_finder.GetApiAvailability('jsonBetaAPI')) self._avail_finder.GetAPIAvailability('jsonBetaAPI'))
self.assertEqual( self.assertEqual(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[20], 20)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[20], 20)),
self._avail_finder.GetApiAvailability('jsonStableAPI')) self._avail_finder.GetAPIAvailability('jsonStableAPI'))
# Testing a whitelisted API. # Testing a whitelisted API.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27)), AvailabilityInfo(ChannelInfo('beta', CANNED_BRANCHES[27], 27)),
self._avail_finder.GetApiAvailability('declarativeWebRequest')) self._avail_finder.GetAPIAvailability('declarativeWebRequest'))
# Testing APIs found only by checking file system existence. # Testing APIs found only by checking file system existence.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[23], 23)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[23], 23)),
self._avail_finder.GetApiAvailability('windows')) self._avail_finder.GetAPIAvailability('windows'))
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[18], 18)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[18], 18)),
self._avail_finder.GetApiAvailability('tabs')) self._avail_finder.GetAPIAvailability('tabs'))
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[18], 18)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[18], 18)),
self._avail_finder.GetApiAvailability('input.ime')) self._avail_finder.GetAPIAvailability('input.ime'))
# Testing API channel existence for _api_features.json. # Testing API channel existence for _api_features.json.
# Listed as 'dev' on |beta|, 'dev' on |dev|. # Listed as 'dev' on |beta|, 'dev' on |dev|.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)), AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
self._avail_finder.GetApiAvailability('systemInfo.stuff')) self._avail_finder.GetAPIAvailability('systemInfo.stuff'))
# Listed as 'stable' on |beta|. # Listed as 'stable' on |beta|.
self.assertEquals( self.assertEquals(
AvailabilityInfo( AvailabilityInfo(
ChannelInfo('beta', CANNED_BRANCHES[27], 27), ChannelInfo('beta', CANNED_BRANCHES[27], 27),
scheduled=28), scheduled=28),
self._avail_finder.GetApiAvailability('systemInfo.cpu')) self._avail_finder.GetAPIAvailability('systemInfo.cpu'))
# Testing API channel existence for _manifest_features.json. # Testing API channel existence for _manifest_features.json.
# Listed as 'trunk' on all channels. # Listed as 'trunk' on all channels.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')), AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
self._avail_finder.GetApiAvailability('sync')) self._avail_finder.GetAPIAvailability('sync'))
# No records of API until |trunk|. # No records of API until |trunk|.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')), AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
self._avail_finder.GetApiAvailability('history')) self._avail_finder.GetAPIAvailability('history'))
# Listed as 'dev' on |dev|. # Listed as 'dev' on |dev|.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)), AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
self._avail_finder.GetApiAvailability('storage')) self._avail_finder.GetAPIAvailability('storage'))
# Stable in _manifest_features and into pre-18 versions. # Stable in _manifest_features and into pre-18 versions.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[8], 8)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[8], 8)),
self._avail_finder.GetApiAvailability('pageAction')) self._avail_finder.GetAPIAvailability('pageAction'))
# Testing API channel existence for _permission_features.json. # Testing API channel existence for _permission_features.json.
# Listed as 'beta' on |trunk|. # Listed as 'beta' on |trunk|.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')), AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
self._avail_finder.GetApiAvailability('falseBetaAPI')) self._avail_finder.GetAPIAvailability('falseBetaAPI'))
# Listed as 'trunk' on |trunk|. # Listed as 'trunk' on |trunk|.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')), AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
self._avail_finder.GetApiAvailability('trunkAPI')) self._avail_finder.GetAPIAvailability('trunkAPI'))
# Listed as 'trunk' on all development channels. # Listed as 'trunk' on all development channels.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')), AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
self._avail_finder.GetApiAvailability('declarativeContent')) self._avail_finder.GetAPIAvailability('declarativeContent'))
# Listed as 'dev' on all development channels. # Listed as 'dev' on all development channels.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)), AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
self._avail_finder.GetApiAvailability('bluetooth')) self._avail_finder.GetAPIAvailability('bluetooth'))
# Listed as 'dev' on |dev|. # Listed as 'dev' on |dev|.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)), AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
self._avail_finder.GetApiAvailability('cookies')) self._avail_finder.GetAPIAvailability('cookies'))
# Treated as 'stable' APIs. # Treated as 'stable' APIs.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[24], 24)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[24], 24)),
self._avail_finder.GetApiAvailability('alarms')) self._avail_finder.GetAPIAvailability('alarms'))
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[21], 21)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[21], 21)),
self._avail_finder.GetApiAvailability('bookmarks')) self._avail_finder.GetAPIAvailability('bookmarks'))
# Testing older API existence using extension_api.json. # Testing older API existence using extension_api.json.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[6], 6)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[6], 6)),
self._avail_finder.GetApiAvailability('menus')) self._avail_finder.GetAPIAvailability('menus'))
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[5], 5)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[5], 5)),
self._avail_finder.GetApiAvailability('idle')) self._avail_finder.GetAPIAvailability('idle'))
# Switches between _features.json files across branches. # Switches between _features.json files across branches.
# Listed as 'trunk' on all channels, in _api, _permission, or _manifest. # Listed as 'trunk' on all channels, in _api, _permission, or _manifest.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')), AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
self._avail_finder.GetApiAvailability('contextMenus')) self._avail_finder.GetAPIAvailability('contextMenus'))
# Moves between _permission and _manifest as file system is traversed. # Moves between _permission and _manifest as file system is traversed.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[23], 23)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[23], 23)),
self._avail_finder.GetApiAvailability('systemInfo.display')) self._avail_finder.GetAPIAvailability('systemInfo.display'))
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[17], 17)), AvailabilityInfo(ChannelInfo('stable', CANNED_BRANCHES[17], 17)),
self._avail_finder.GetApiAvailability('webRequest')) self._avail_finder.GetAPIAvailability('webRequest'))
# Mid-upgrade cases: # Mid-upgrade cases:
# Listed as 'dev' on |beta| and 'beta' on |dev|. # Listed as 'dev' on |beta| and 'beta' on |dev|.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)), AvailabilityInfo(ChannelInfo('dev', CANNED_BRANCHES[28], 28)),
self._avail_finder.GetApiAvailability('notifications')) self._avail_finder.GetAPIAvailability('notifications'))
# Listed as 'beta' on |stable|, 'dev' on |beta| ... until |stable| on trunk. # Listed as 'beta' on |stable|, 'dev' on |beta| ... until |stable| on trunk.
self.assertEquals( self.assertEquals(
AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')), AvailabilityInfo(ChannelInfo('trunk', 'trunk', 'trunk')),
self._avail_finder.GetApiAvailability('events')) self._avail_finder.GetAPIAvailability('events'))
def testGetApiNodeAvailability(self): def testGetAPINodeAvailability(self):
# Allow the LookupResult constructions below to take just one line. # Allow the LookupResult constructions below to take just one line.
lookup_result = api_schema_graph.LookupResult lookup_result = api_schema_graph.LookupResult
availability_graph = self._node_avail_finder.GetApiNodeAvailability('tabs') availability_graph = self._node_avail_finder.GetAPINodeAvailability('tabs')
self.assertEquals( self.assertEquals(
lookup_result(True, self._branch_utility.GetChannelInfo('trunk')), lookup_result(True, self._branch_utility.GetChannelInfo('trunk')),
......
...@@ -106,7 +106,7 @@ class CompiledFileSystem(object): ...@@ -106,7 +106,7 @@ class CompiledFileSystem(object):
category='json') category='json')
@memoize @memoize
def ForApiSchema(self, file_system): def ForAPISchema(self, file_system):
'''Creates a CompiledFileSystem for parsing raw JSON or IDL API schema '''Creates a CompiledFileSystem for parsing raw JSON or IDL API schema
data and formatting it so that it can be used by other classes, such data and formatting it so that it can be used by other classes, such
as Model and APISchemaGraph. as Model and APISchemaGraph.
......
...@@ -32,21 +32,21 @@ class WhatsNewDataSource(DataSource): ...@@ -32,21 +32,21 @@ class WhatsNewDataSource(DataSource):
'version': change['version'] 'version': change['version']
} for change_id, change in whats_new_json.iteritems()] } for change_id, change in whats_new_json.iteritems()]
def _GetApiVersion(self, platform, api_name): def _GetAPIVersion(self, platform, api_name):
version = None version = None
category = self._api_categorizer.GetCategory(platform, api_name) category = self._api_categorizer.GetCategory(platform, api_name)
if category == 'chrome': if category == 'chrome':
channel_info = self._availability_finder.GetApiAvailability( channel_info = self._availability_finder.GetAPIAvailability(
api_name).channel_info api_name).channel_info
channel = channel_info.channel channel = channel_info.channel
if channel == 'stable': if channel == 'stable':
version = channel_info.version version = channel_info.version
return version return version
def _GenerateApiListWithVersion(self, platform): def _GenerateAPIListWithVersion(self, platform):
data = [] data = []
for api_name, api_model in self._api_models.IterModels(): for api_name, api_model in self._api_models.IterModels():
version = self._GetApiVersion(platform, api_name) version = self._GetAPIVersion(platform, api_name)
if version: if version:
api = { api = {
'name': api_name, 'name': api_name,
...@@ -64,7 +64,7 @@ class WhatsNewDataSource(DataSource): ...@@ -64,7 +64,7 @@ class WhatsNewDataSource(DataSource):
def _MakeDictByPlatform(platform): def _MakeDictByPlatform(platform):
whats_new_json = whats_new_json_future.Get() whats_new_json = whats_new_json_future.Get()
platform_list = [] platform_list = []
apis = self._GenerateApiListWithVersion(platform) apis = self._GenerateAPIListWithVersion(platform)
apis.extend(self._GenerateChangesListWithVersion(platform, apis.extend(self._GenerateChangesListWithVersion(platform,
whats_new_json)) whats_new_json))
apis.sort(key=itemgetter('version'), reverse=True) apis.sort(key=itemgetter('version'), reverse=True)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment