Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
|
ahernandez
2014/06/26 23:53:32
I reorganized a lot of the tests in this file beca
| |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 | 5 |
| 6 import json | 6 import json |
| 7 import os | 7 import os |
| 8 import sys | 8 import sys |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| 11 from api_data_source import (_JSCModel, | 11 from api_data_source import (_JSCModel, |
| 12 _FormatValue, | 12 _FormatValue, |
| 13 _GetEventByNameFromEvents) | 13 _GetEventByNameFromEvents) |
| 14 from availability_finder import AvailabilityInfo | 14 from api_schema_graph import APISchemaGraph |
| 15 from branch_utility import ChannelInfo | 15 from availability_finder import AvailabilityFinder, AvailabilityInfo |
| 16 from branch_utility import BranchUtility, ChannelInfo | |
| 17 from compiled_file_system import CompiledFileSystem | |
| 16 from extensions_paths import CHROME_EXTENSIONS | 18 from extensions_paths import CHROME_EXTENSIONS |
| 17 from fake_host_file_system_provider import FakeHostFileSystemProvider | 19 from fake_host_file_system_provider import FakeHostFileSystemProvider |
| 20 from fake_url_fetcher import FakeUrlFetcher | |
| 18 from features_bundle import FeaturesBundle | 21 from features_bundle import FeaturesBundle |
| 19 from file_system import FileNotFoundError | 22 from file_system import FileNotFoundError |
| 20 from future import Future | 23 from future import Future |
| 24 from host_file_system_iterator import HostFileSystemIterator | |
| 21 from object_store_creator import ObjectStoreCreator | 25 from object_store_creator import ObjectStoreCreator |
| 22 from server_instance import ServerInstance | 26 from server_instance import ServerInstance |
| 27 from test_data.api_data_source.canned_trunk_fs import CANNED_TRUNK_FS_DATA | |
| 23 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES) | 28 from test_data.canned_data import (CANNED_API_FILE_SYSTEM_DATA, CANNED_BRANCHES) |
| 24 from test_data.api_data_source.canned_trunk_fs import CANNED_TRUNK_FS_DATA | 29 from test_data.object_level_availability.tabs import TABS_SCHEMA_BRANCHES |
| 25 from test_file_system import TestFileSystem | 30 from test_file_system import TestFileSystem |
| 26 from test_util import Server2Path | 31 from test_util import Server2Path |
| 27 from third_party.json_schema_compiler.memoize import memoize | 32 from third_party.json_schema_compiler.memoize import memoize |
| 28 | 33 |
| 29 | 34 |
| 30 def _MakeLink(href, text): | |
| 31 return '<a href="%s">%s</a>' % (href, text) | |
| 32 | |
| 33 | |
| 34 def _GetType(dict_, name): | |
| 35 for type_ in dict_['types']: | |
| 36 if type_['name'] == name: | |
| 37 return type_ | |
| 38 | |
| 39 | |
| 40 class _FakeTemplateCache(object): | 35 class _FakeTemplateCache(object): |
| 41 | 36 |
| 42 def GetFromFile(self, key): | 37 def GetFromFile(self, key): |
| 43 return Future(value='handlebar %s' % key) | 38 return Future(value='handlebar %s' % key) |
| 44 | 39 |
| 45 | 40 |
| 41 class _FakeAvailabilityFinder(object): | |
| 42 def __init__(self, fake_availability): | |
| 43 self._fake_availability = fake_availability | |
| 44 | |
| 45 def GetAPIAvailability(self, api_name): | |
| 46 return self._fake_availability | |
| 47 | |
| 48 def GetAPINodeAvailability(self, api_name): | |
| 49 '''The tests that use this fake class don't | |
| 50 use the node availability, so just return a | |
| 51 dummy graph. | |
| 52 ''' | |
| 53 return APISchemaGraph(_graph={'dummy': 'graph'}) | |
| 54 | |
| 55 | |
| 46 class _FakeFeaturesBundle(object): | 56 class _FakeFeaturesBundle(object): |
| 47 def GetAPIFeatures(self): | 57 def GetAPIFeatures(self): |
| 48 return Future(value={ | 58 return Future(value={ |
| 49 'bluetooth': {'value': True}, | 59 'bluetooth': {'value': True}, |
| 50 'contextMenus': {'value': True}, | 60 'contextMenus': {'value': True}, |
| 51 'jsonStableAPI': {'value': True}, | 61 'jsonStableAPI': {'value': True}, |
| 52 'idle': {'value': True}, | 62 'idle': {'value': True}, |
| 53 'input.ime': {'value': True}, | 63 'input.ime': {'value': True}, |
| 54 'tabs': {'value': True} | 64 'tabs': {'value': True} |
| 55 }) | 65 }) |
| 56 | 66 |
| 57 | 67 |
| 58 class APIDataSourceTest(unittest.TestCase): | 68 class APIDataSourceTest(unittest.TestCase): |
| 59 | |
| 60 def setUp(self): | 69 def setUp(self): |
| 61 self._base_path = Server2Path('test_data', 'test_json') | 70 self._base_path = Server2Path('test_data', 'test_json') |
| 62 | 71 |
| 63 server_instance = ServerInstance.ForTest( | 72 server_instance = ServerInstance.ForTest( |
| 64 TestFileSystem(CANNED_TRUNK_FS_DATA, relative_to=CHROME_EXTENSIONS)) | 73 TestFileSystem(CANNED_TRUNK_FS_DATA, relative_to=CHROME_EXTENSIONS)) |
| 65 file_system = server_instance.host_file_system_provider.GetTrunk() | 74 file_system = server_instance.host_file_system_provider.GetTrunk() |
| 66 self._json_cache = server_instance.compiled_fs_factory.ForJson(file_system) | 75 self._json_cache = server_instance.compiled_fs_factory.ForJson(file_system) |
| 67 self._features_bundle = FeaturesBundle(file_system, | 76 self._features_bundle = FeaturesBundle(file_system, |
| 68 server_instance.compiled_fs_factory, | 77 server_instance.compiled_fs_factory, |
| 69 server_instance.object_store_creator, | 78 server_instance.object_store_creator, |
| 70 'extensions') | 79 'extensions') |
| 71 self._api_models = server_instance.platform_bundle.GetAPIModels( | 80 self._api_models = server_instance.platform_bundle.GetAPIModels( |
| 72 'extensions') | 81 'extensions') |
| 73 self._fake_availability = AvailabilityInfo(ChannelInfo('stable', '396', 5)) | 82 self._fake_availability = AvailabilityInfo(ChannelInfo('stable', '396', 5)) |
| 74 | 83 |
| 75 # Used for testGetAPIAvailability() so that valid-ish data is processed. | |
| 76 server_instance = ServerInstance.ForTest( | |
| 77 file_system_provider=FakeHostFileSystemProvider( | |
| 78 CANNED_API_FILE_SYSTEM_DATA)) | |
| 79 self._avail_api_models = server_instance.platform_bundle.GetAPIModels( | |
| 80 'extensions') | |
| 81 self._avail_json_cache = server_instance.compiled_fs_factory.ForJson( | |
| 82 server_instance.host_file_system_provider.GetTrunk()) | |
| 83 self._avail_finder = server_instance.platform_bundle.GetAvailabilityFinder( | |
| 84 'extensions') | |
| 85 | |
| 86 def _ReadLocalFile(self, filename): | 84 def _ReadLocalFile(self, filename): |
| 87 with open(os.path.join(self._base_path, filename), 'r') as f: | 85 with open(os.path.join(self._base_path, filename), 'r') as f: |
| 88 return f.read() | 86 return f.read() |
| 89 | 87 |
| 90 def _LoadJSON(self, filename): | 88 def _LoadJSON(self, filename): |
| 91 return json.loads(self._ReadLocalFile(filename)) | 89 return json.loads(self._ReadLocalFile(filename)) |
| 92 | 90 |
| 91 def _FakeLoadAddRulesSchema(self): | |
| 92 events = self._LoadJSON('add_rules_def_test.json') | |
| 93 return Future(value=_GetEventByNameFromEvents(events)) | |
| 94 | |
| 95 def testFormatValue(self): | |
| 96 self.assertEquals('1,234,567', _FormatValue(1234567)) | |
| 97 self.assertEquals('67', _FormatValue(67)) | |
| 98 self.assertEquals('234,567', _FormatValue(234567)) | |
| 99 | |
| 100 def testGetEventByNameFromEvents(self): | |
| 101 events = {} | |
| 102 # Missing 'types' completely. | |
| 103 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events) | |
| 104 | |
| 105 events['types'] = [] | |
| 106 # No type 'Event' defined. | |
| 107 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events) | |
| 108 | |
| 109 events['types'].append({ 'name': 'Event', | |
| 110 'functions': []}) | |
| 111 add_rules = { "name": "addRules" } | |
| 112 events['types'][0]['functions'].append(add_rules) | |
| 113 self.assertEqual(add_rules, | |
| 114 _GetEventByNameFromEvents(events)['addRules']) | |
| 115 | |
| 116 events['types'][0]['functions'].append(add_rules) | |
| 117 # Duplicates are an error. | |
| 118 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events) | |
| 119 | |
| 93 def testCreateId(self): | 120 def testCreateId(self): |
| 121 fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability) | |
| 94 dict_ = _JSCModel(self._api_models.GetModel('tester').Get(), | 122 dict_ = _JSCModel(self._api_models.GetModel('tester').Get(), |
| 95 self._fake_availability, | 123 fake_avail_finder, |
| 96 self._json_cache, | 124 self._json_cache, |
| 97 _FakeTemplateCache(), | 125 _FakeTemplateCache(), |
| 98 self._features_bundle, | 126 self._features_bundle, |
| 99 None).ToDict() | 127 None).ToDict() |
| 100 self.assertEquals('type-TypeA', dict_['types'][0]['id']) | 128 self.assertEquals('type-TypeA', dict_['types'][0]['id']) |
| 101 self.assertEquals('property-TypeA-b', | 129 self.assertEquals('property-TypeA-b', |
| 102 dict_['types'][0]['properties'][0]['id']) | 130 dict_['types'][0]['properties'][0]['id']) |
| 103 self.assertEquals('method-get', dict_['functions'][0]['id']) | 131 self.assertEquals('method-get', dict_['functions'][0]['id']) |
| 104 self.assertEquals('event-EventA', dict_['events'][0]['id']) | 132 self.assertEquals('event-EventA', dict_['events'][0]['id']) |
| 105 | 133 |
| 106 # TODO(kalman): re-enable this when we have a rebase option. | 134 # TODO(kalman): re-enable this when we have a rebase option. |
| 107 def DISABLED_testToDict(self): | 135 def DISABLED_testToDict(self): |
| 136 fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability) | |
| 108 expected_json = self._LoadJSON('expected_tester.json') | 137 expected_json = self._LoadJSON('expected_tester.json') |
| 109 dict_ = _JSCModel(self._api_models.GetModel('tester').Get(), | 138 dict_ = _JSCModel(self._api_models.GetModel('tester').Get(), |
| 110 self._fake_availability, | 139 fake_avail_finder, |
| 111 self._json_cache, | 140 self._json_cache, |
| 112 _FakeTemplateCache(), | 141 _FakeTemplateCache(), |
| 113 self._features_bundle, | 142 self._features_bundle, |
| 114 None).ToDict() | 143 None).ToDict() |
| 115 self.assertEquals(expected_json, dict_) | 144 self.assertEquals(expected_json, dict_) |
| 116 | 145 |
| 117 def testFormatValue(self): | 146 def testAddRules(self): |
| 118 self.assertEquals('1,234,567', _FormatValue(1234567)) | 147 fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability) |
| 119 self.assertEquals('67', _FormatValue(67)) | 148 dict_ = _JSCModel(self._api_models.GetModel('add_rules_tester').Get(), |
| 120 self.assertEquals('234,567', _FormatValue(234567)) | 149 fake_avail_finder, |
| 121 | 150 #self._fake_availability, |
| 122 def testGetAPIAvailability(self): | |
| 123 api_availabilities = { | |
| 124 'bluetooth': 28, | |
| 125 'contextMenus': 'trunk', | |
| 126 'jsonStableAPI': 20, | |
| 127 'idle': 5, | |
| 128 'input.ime': 18, | |
| 129 'tabs': 18 | |
| 130 } | |
| 131 for api_name, availability in api_availabilities.iteritems(): | |
| 132 model_dict = _JSCModel( | |
| 133 self._avail_api_models.GetModel(api_name).Get(), | |
| 134 self._avail_finder.GetAPIAvailability(api_name), | |
| 135 self._avail_json_cache, | |
| 136 _FakeTemplateCache(), | |
| 137 _FakeFeaturesBundle(), | |
| 138 None).ToDict() | |
| 139 self.assertEquals(availability, | |
| 140 model_dict['introList'][1]['content'][0]['version']) | |
| 141 | |
| 142 def testGetIntroList(self): | |
| 143 model = _JSCModel(self._api_models.GetModel('tester').Get(), | |
| 144 self._fake_availability, | |
| 145 self._json_cache, | 151 self._json_cache, |
| 146 _FakeTemplateCache(), | 152 _FakeTemplateCache(), |
| 147 self._features_bundle, | 153 self._features_bundle, |
| 154 self._FakeLoadAddRulesSchema()).ToDict() | |
| 155 | |
| 156 # Check that the first event has the addRulesFunction defined. | |
| 157 self.assertEquals('add_rules_tester', dict_['name']) | |
| 158 self.assertEquals('rules', dict_['events'][0]['name']) | |
| 159 self.assertEquals('notable_name_to_check_for', | |
| 160 dict_['events'][0]['byName']['addRules'][ | |
| 161 'parameters'][0]['name']) | |
| 162 | |
| 163 # Check that the second event has addListener defined. | |
| 164 self.assertEquals('noRules', dict_['events'][1]['name']) | |
| 165 self.assertEquals('add_rules_tester', dict_['name']) | |
| 166 self.assertEquals('noRules', dict_['events'][1]['name']) | |
| 167 self.assertEquals('callback', | |
| 168 dict_['events'][0]['byName']['addListener'][ | |
| 169 'parameters'][0]['name']) | |
| 170 | |
| 171 def testGetIntroList(self): | |
| 172 fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability) | |
| 173 model = _JSCModel(self._api_models.GetModel('tester').Get(), | |
| 174 fake_avail_finder, | |
| 175 self._json_cache, | |
| 176 _FakeTemplateCache(), | |
| 177 self._features_bundle, | |
| 148 None) | 178 None) |
| 149 expected_list = [ | 179 expected_list = [ |
| 150 { 'title': 'Description', | 180 { 'title': 'Description', |
| 151 'content': [ | 181 'content': [ |
| 152 { 'text': 'a test api' } | 182 { 'text': 'a test api' } |
| 153 ] | 183 ] |
| 154 }, | 184 }, |
| 155 { 'title': 'Availability', | 185 { 'title': 'Availability', |
| 156 'content': [ | 186 'content': [ |
| 157 { 'partial': 'handlebar chrome/common/extensions/docs/' + | 187 { 'partial': 'handlebar chrome/common/extensions/docs/' + |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 179 { 'title': 'Learn More', | 209 { 'title': 'Learn More', |
| 180 'content': [ | 210 'content': [ |
| 181 { 'link': 'https://tester.test.com/welcome.html', | 211 { 'link': 'https://tester.test.com/welcome.html', |
| 182 'text': 'Welcome!' | 212 'text': 'Welcome!' |
| 183 } | 213 } |
| 184 ] | 214 ] |
| 185 } | 215 } |
| 186 ] | 216 ] |
| 187 self.assertEquals(model._GetIntroTableList(), expected_list) | 217 self.assertEquals(model._GetIntroTableList(), expected_list) |
| 188 | 218 |
| 219 fake_avail_finder = _FakeAvailabilityFinder( | |
| 220 AvailabilityInfo(ChannelInfo('beta', '1453', 27), scheduled=28)) | |
| 189 # Tests the same data with a scheduled availability. | 221 # Tests the same data with a scheduled availability. |
| 190 model = _JSCModel(self._api_models.GetModel('tester').Get(), | 222 model = _JSCModel(self._api_models.GetModel('tester').Get(), |
| 191 AvailabilityInfo(ChannelInfo('beta', '1453', 27), scheduled=28), | 223 fake_avail_finder, |
| 192 self._json_cache, | 224 self._json_cache, |
| 193 _FakeTemplateCache(), | 225 _FakeTemplateCache(), |
| 194 self._features_bundle, | 226 self._features_bundle, |
| 195 None) | 227 None) |
| 196 expected_list[1] = { | 228 expected_list[1] = { |
| 197 'title': 'Availability', | 229 'title': 'Availability', |
| 198 'content': [ | 230 'content': [ |
| 199 { 'partial': 'handlebar chrome/common/extensions/docs/' + | 231 { 'partial': 'handlebar chrome/common/extensions/docs/' + |
| 200 'templates/private/intro_tables/beta_message.html', | 232 'templates/private/intro_tables/beta_message.html', |
| 201 'version': 27, | 233 'version': 27, |
| 202 'scheduled': 28 | 234 'scheduled': 28 |
| 203 } | 235 } |
| 204 ] | 236 ] |
| 205 } | 237 } |
| 206 self.assertEquals(model._GetIntroTableList(), expected_list) | 238 self.assertEquals(model._GetIntroTableList(), expected_list) |
| 207 | 239 |
| 208 def testGetEventByNameFromEvents(self): | |
| 209 events = {} | |
| 210 # Missing 'types' completely. | |
| 211 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events) | |
| 212 | 240 |
| 213 events['types'] = [] | 241 class APIDataSourceWithoutNodeAvailabilityTest(unittest.TestCase): |
| 214 # No type 'Event' defined. | 242 def setUp(self): |
| 215 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events) | 243 server_instance = ServerInstance.ForTest( |
| 244 file_system_provider=FakeHostFileSystemProvider( | |
| 245 CANNED_API_FILE_SYSTEM_DATA)) | |
| 246 self._api_models = server_instance.platform_bundle.GetAPIModels( | |
| 247 'extensions') | |
| 248 self._json_cache = server_instance.compiled_fs_factory.ForJson( | |
| 249 server_instance.host_file_system_provider.GetTrunk()) | |
| 250 self._avail_finder = server_instance.platform_bundle.GetAvailabilityFinder( | |
| 251 'extensions') | |
| 216 | 252 |
| 217 events['types'].append({ 'name': 'Event', | |
| 218 'functions': []}) | |
| 219 add_rules = { "name": "addRules" } | |
| 220 events['types'][0]['functions'].append(add_rules) | |
| 221 self.assertEqual(add_rules, | |
| 222 _GetEventByNameFromEvents(events)['addRules']) | |
| 223 | 253 |
| 224 events['types'][0]['functions'].append(add_rules) | 254 def testGetAPIAvailability(self): |
| 225 # Duplicates are an error. | 255 api_availabilities = { |
| 226 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events) | 256 'bluetooth': 28, |
| 257 'contextMenus': 'trunk', | |
| 258 'jsonStableAPI': 20, | |
| 259 'idle': 5, | |
| 260 'input.ime': 18, | |
| 261 'tabs': 18 | |
| 262 } | |
| 263 for api_name, availability in api_availabilities.iteritems(): | |
| 264 model_dict = _JSCModel( | |
| 265 self._api_models.GetModel(api_name).Get(), | |
| 266 self._avail_finder, | |
| 267 self._json_cache, | |
| 268 _FakeTemplateCache(), | |
| 269 _FakeFeaturesBundle(), | |
| 270 None).ToDict() | |
| 271 self.assertEquals(availability, | |
| 272 model_dict['introList'][1]['content'][0]['version']) | |
| 227 | 273 |
| 228 def _FakeLoadAddRulesSchema(self): | |
| 229 events = self._LoadJSON('add_rules_def_test.json') | |
| 230 return Future(value=_GetEventByNameFromEvents(events)) | |
| 231 | 274 |
| 232 def testAddRules(self): | 275 class APIDataSourceWithNodeAvailabilityTest(unittest.TestCase): |
| 233 dict_ = _JSCModel(self._api_models.GetModel('add_rules_tester').Get(), | 276 def setUp(self): |
| 234 self._fake_availability, | 277 tabs_unmodified_versions = (16, 20, 23, 24) |
| 235 self._json_cache, | 278 self._branch_utility = BranchUtility( |
| 236 _FakeTemplateCache(), | 279 os.path.join('branch_utility', 'first.json'), |
| 237 self._features_bundle, | 280 os.path.join('branch_utility', 'second.json'), |
| 238 self._FakeLoadAddRulesSchema()).ToDict() | 281 FakeUrlFetcher(Server2Path('test_data')), |
| 282 ObjectStoreCreator.ForTest()) | |
| 283 self._node_fs_creator = FakeHostFileSystemProvider(TABS_SCHEMA_BRANCHES) | |
| 284 self._node_fs_iterator = HostFileSystemIterator(self._node_fs_creator, | |
| 285 self._branch_utility) | |
| 286 test_object_store = ObjectStoreCreator.ForTest() | |
| 287 self._avail_finder = AvailabilityFinder( | |
| 288 self._branch_utility, | |
| 289 CompiledFileSystem.Factory(test_object_store), | |
| 290 self._node_fs_iterator, | |
| 291 self._node_fs_creator.GetTrunk(), | |
| 292 test_object_store, | |
| 293 'extensions') | |
| 239 | 294 |
| 240 # Check that the first event has the addRulesFunction defined. | 295 server_instance = ServerInstance.ForTest( |
| 241 self.assertEquals('add_rules_tester', dict_['name']) | 296 file_system_provider=FakeHostFileSystemProvider( |
| 242 self.assertEquals('rules', dict_['events'][0]['name']) | 297 TABS_SCHEMA_BRANCHES)) |
| 243 self.assertEquals('notable_name_to_check_for', | 298 self._api_models = server_instance.platform_bundle.GetAPIModels( |
| 244 dict_['events'][0]['byName']['addRules'][ | 299 'extensions') |
| 245 'parameters'][0]['name']) | 300 self._json_cache = server_instance.compiled_fs_factory.ForJson( |
| 301 server_instance.host_file_system_provider.GetTrunk()) | |
| 246 | 302 |
| 247 # Check that the second event has addListener defined. | 303 # Imitate the actual SVN file system by incrementing the stats for paths |
| 248 self.assertEquals('noRules', dict_['events'][1]['name']) | 304 # where an API schema has changed. |
| 249 self.assertEquals('add_rules_tester', dict_['name']) | 305 last_stat = type('last_stat', (object,), {'val': 0}) |
| 250 self.assertEquals('noRules', dict_['events'][1]['name']) | 306 |
| 251 self.assertEquals('callback', | 307 def stat_paths(file_system, channel_info): |
| 252 dict_['events'][0]['byName']['addListener'][ | 308 if channel_info.version not in tabs_unmodified_versions: |
| 253 'parameters'][0]['name']) | 309 last_stat.val += 1 |
| 310 # HACK: |file_system| is a MockFileSystem backed by a TestFileSystem. | |
| 311 # Increment the TestFileSystem stat count. | |
| 312 file_system._file_system.IncrementStat(by=last_stat.val) | |
| 313 # Continue looping. The iterator will stop after 'trunk' automatically. | |
| 314 return True | |
| 315 | |
| 316 # Use the HostFileSystemIterator created above to change global stat values | |
| 317 # for the TestFileSystems that it creates. | |
| 318 self._node_fs_iterator.Ascending( | |
| 319 # The earliest version represented with the tabs' test data is 13. | |
| 320 self._branch_utility.GetStableChannelInfo(13), | |
| 321 stat_paths) | |
| 322 | |
| 323 def testGetAPINodeAvailability(self): | |
| 324 def assertEquals(node, actual): | |
| 325 node_availabilities = { | |
| 326 'tabs.Tab': None, | |
| 327 'tabs.InjectDetails': 25 | |
| 328 } | |
| 329 self.assertEquals(node_availabilities[node], actual) | |
| 330 | |
| 331 model_dict = _JSCModel( | |
| 332 self._api_models.GetModel('tabs').Get(), | |
| 333 self._avail_finder, | |
| 334 self._json_cache, | |
| 335 _FakeTemplateCache(), | |
| 336 _FakeFeaturesBundle(), | |
| 337 None).ToDict() | |
| 338 | |
| 339 # Test nodes that have the same availability as their parent. | |
|
ahernandez
2014/06/26 23:53:31
There are only two tests for this because I'm only
| |
| 340 assertEquals('tabs.Tab', model_dict['types'][0]['availability']) | |
| 341 # Test nodes with varying availabilities. | |
| 342 assertEquals('tabs.InjectDetails', | |
| 343 model_dict['types'][1]['availability']['version']) | |
| 344 | |
| 254 | 345 |
| 255 if __name__ == '__main__': | 346 if __name__ == '__main__': |
| 256 unittest.main() | 347 unittest.main() |
| OLD | NEW |