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

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

Issue 213673002: Add support for "documented_in" annotation in json api schema (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bump version (again) Created 6 years, 9 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 (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
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 def Create(self, *args, **kwargs): 58 def Create(self, *args, **kwargs):
59 return self 59 return self
60 60
61 def get(self, key, disable_refs=False): 61 def get(self, key, disable_refs=False):
62 if key not in self._json: 62 if key not in self._json:
63 raise FileNotFoundError(key) 63 raise FileNotFoundError(key)
64 return self._json[key] 64 return self._json[key]
65 65
66 66
67 class _FakeNamespace(object):
68
69 def __init__(self):
70 self.documentation_options = {}
71
72
67 class _FakeAPIModels(object): 73 class _FakeAPIModels(object):
68 74
69 def __init__(self, names): 75 def __init__(self, names):
70 self._names = names 76 self._names = names
71 77
72 def GetNames(self): 78 def GetNames(self):
73 return self._names 79 return self._names
74 80
81 def GetModel(self, name):
82 return Future(value=_FakeNamespace())
83
75 84
76 class _FakeTemplateCache(object): 85 class _FakeTemplateCache(object):
77 86
78 def GetFromFile(self, key): 87 def GetFromFile(self, key):
79 return Future(value='handlebar %s' % key) 88 return Future(value='handlebar %s' % key)
80 89
81 90
82 class APIDataSourceTest(unittest.TestCase): 91 class APIDataSourceTest(unittest.TestCase):
83 92
84 def setUp(self): 93 def setUp(self):
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 def testFormatDescription(self): 162 def testFormatDescription(self):
154 dict_ = _JSCModel('ref_test', 163 dict_ = _JSCModel('ref_test',
155 self._api_models, 164 self._api_models,
156 self._CreateRefResolver('ref_test_data_source.json'), 165 self._CreateRefResolver('ref_test_data_source.json'),
157 False, 166 False,
158 _FakeAvailabilityFinder(), 167 _FakeAvailabilityFinder(),
159 self._json_cache, 168 self._json_cache,
160 _FakeTemplateCache(), 169 _FakeTemplateCache(),
161 self._features_bundle, 170 self._features_bundle,
162 None).ToDict() 171 None).ToDict()
163 self.assertEquals(_MakeLink('ref_test.html#type-type2', 'type2'), 172 self.assertEquals(_MakeLink('ref_test#type-type2', 'type2'),
164 _GetType(dict_, 'type1')['description']) 173 _GetType(dict_, 'type1')['description'])
165 self.assertEquals( 174 self.assertEquals(
166 'A %s, or %s' % (_MakeLink('ref_test.html#type-type3', 'type3'), 175 'A %s, or %s' % (_MakeLink('ref_test#type-type3', 'type3'),
167 _MakeLink('ref_test.html#type-type2', 'type2')), 176 _MakeLink('ref_test#type-type2', 'type2')),
168 _GetType(dict_, 'type2')['description']) 177 _GetType(dict_, 'type2')['description'])
169 self.assertEquals( 178 self.assertEquals(
170 '%s != %s' % (_MakeLink('other.html#type-type2', 'other.type2'), 179 '%s != %s' % (_MakeLink('other#type-type2', 'other.type2'),
171 _MakeLink('ref_test.html#type-type2', 'type2')), 180 _MakeLink('ref_test#type-type2', 'type2')),
172 _GetType(dict_, 'type3')['description']) 181 _GetType(dict_, 'type3')['description'])
173 182
174 183
175 def testGetApiAvailability(self): 184 def testGetApiAvailability(self):
176 api_availabilities = { 185 api_availabilities = {
177 'bluetooth': ChannelInfo('dev', CANNED_BRANCHES[28], 28), 186 'bluetooth': ChannelInfo('dev', CANNED_BRANCHES[28], 28),
178 'contextMenus': ChannelInfo('trunk', CANNED_BRANCHES['trunk'], 'trunk'), 187 'contextMenus': ChannelInfo('trunk', CANNED_BRANCHES['trunk'], 'trunk'),
179 'jsonStableAPI': ChannelInfo('stable', CANNED_BRANCHES[20], 20), 188 'jsonStableAPI': ChannelInfo('stable', CANNED_BRANCHES[20], 20),
180 'idle': ChannelInfo('stable', CANNED_BRANCHES[5], 5), 189 'idle': ChannelInfo('stable', CANNED_BRANCHES[5], 5),
181 'input.ime': ChannelInfo('stable', CANNED_BRANCHES[18], 18), 190 'input.ime': ChannelInfo('stable', CANNED_BRANCHES[18], 18),
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 # Check that the second event has addListener defined. 296 # Check that the second event has addListener defined.
288 self.assertEquals('noRules', dict_['events'][1]['name']) 297 self.assertEquals('noRules', dict_['events'][1]['name'])
289 self.assertEquals('add_rules_tester', dict_['name']) 298 self.assertEquals('add_rules_tester', dict_['name'])
290 self.assertEquals('noRules', dict_['events'][1]['name']) 299 self.assertEquals('noRules', dict_['events'][1]['name'])
291 self.assertEquals('callback', 300 self.assertEquals('callback',
292 dict_['events'][0]['byName']['addListener'][ 301 dict_['events'][0]['byName']['addListener'][
293 'parameters'][0]['name']) 302 'parameters'][0]['name'])
294 303
295 if __name__ == '__main__': 304 if __name__ == '__main__':
296 unittest.main() 305 unittest.main()
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/webview_tag.json ('k') | chrome/common/extensions/docs/server2/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698