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

Side by Side Diff: chrome/common/extensions/docs/server2/api_data_source_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: Cleans up style 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 (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 24 matching lines...) Expand all
35 if type_['name'] == name: 35 if type_['name'] == name:
36 return type_ 36 return type_
37 37
38 38
39 class _FakeAvailabilityFinder(object): 39 class _FakeAvailabilityFinder(object):
40 40
41 def GetApiAvailability(self, version): 41 def GetApiAvailability(self, version):
42 return ChannelInfo('stable', '396', 5) 42 return ChannelInfo('stable', '396', 5)
43 43
44 44
45 class _FakeScheduledAvailabilityFinder(object):
46
47 def GetApiAvailability(self, version):
48 return ChannelInfo('dev', '1500', 28, 28)
49
50
45 class _FakeTemplateCache(object): 51 class _FakeTemplateCache(object):
46 52
47 def GetFromFile(self, key): 53 def GetFromFile(self, key):
48 return Future(value='handlebar %s' % key) 54 return Future(value='handlebar %s' % key)
49 55
50 56
51 class APIDataSourceTest(unittest.TestCase): 57 class APIDataSourceTest(unittest.TestCase):
52 58
53 def setUp(self): 59 def setUp(self):
54 self._base_path = Server2Path('test_data', 'test_json') 60 self._base_path = Server2Path('test_data', 'test_json')
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 expected_list = [ 141 expected_list = [
136 { 'title': 'Description', 142 { 'title': 'Description',
137 'content': [ 143 'content': [
138 { 'text': 'a test api' } 144 { 'text': 'a test api' }
139 ] 145 ]
140 }, 146 },
141 { 'title': 'Availability', 147 { 'title': 'Availability',
142 'content': [ 148 'content': [
143 { 'partial': 'handlebar chrome/common/extensions/docs/' + 149 { 'partial': 'handlebar chrome/common/extensions/docs/' +
144 'templates/private/intro_tables/stable_message.html', 150 'templates/private/intro_tables/stable_message.html',
145 'version': 5 151 'version': 5,
152 'scheduled': None
146 } 153 }
147 ] 154 ]
148 }, 155 },
149 { 'title': 'Permissions', 156 { 'title': 'Permissions',
150 'content': [ 157 'content': [
151 { 'class': 'override', 158 { 'class': 'override',
152 'text': '"tester"' 159 'text': '"tester"'
153 }, 160 },
154 { 'text': 'is an API for testing things.' } 161 { 'text': 'is an API for testing things.' }
155 ] 162 ]
156 }, 163 },
157 { 'title': 'Manifest', 164 { 'title': 'Manifest',
158 'content': [ 165 'content': [
159 { 'class': 'code', 166 { 'class': 'code',
160 'text': '"tester": {...}' 167 'text': '"tester": {...}'
161 } 168 }
162 ] 169 ]
163 }, 170 },
164 { 'title': 'Learn More', 171 { 'title': 'Learn More',
165 'content': [ 172 'content': [
166 { 'link': 'https://tester.test.com/welcome.html', 173 { 'link': 'https://tester.test.com/welcome.html',
167 'text': 'Welcome!' 174 'text': 'Welcome!'
168 } 175 }
169 ] 176 ]
170 } 177 }
171 ] 178 ]
172 self.assertEquals(model._GetIntroTableList(), expected_list) 179 self.assertEquals(model._GetIntroTableList(), expected_list)
173 180
181 # Tests the same data with a scheduled availability.
182 model = _JSCModel(self._api_models.GetModel('tester').Get(),
183 _FakeScheduledAvailabilityFinder(),
184 self._json_cache,
185 _FakeTemplateCache(),
186 self._features_bundle,
187 None)
188 expected_list[1] = {
189 'title': 'Availability',
190 'content': [
191 { 'partial': 'handlebar chrome/common/extensions/docs/' +
192 'templates/private/intro_tables/dev_message.html',
193 'version': 28,
194 'scheduled': 28
195 }
196 ]
197 }
198 self.assertEquals(model._GetIntroTableList(), expected_list)
199
174 def testGetEventByNameFromEvents(self): 200 def testGetEventByNameFromEvents(self):
175 events = {} 201 events = {}
176 # Missing 'types' completely. 202 # Missing 'types' completely.
177 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events) 203 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events)
178 204
179 events['types'] = [] 205 events['types'] = []
180 # No type 'Event' defined. 206 # No type 'Event' defined.
181 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events) 207 self.assertRaises(AssertionError, _GetEventByNameFromEvents, events)
182 208
183 events['types'].append({ 'name': 'Event', 209 events['types'].append({ 'name': 'Event',
(...skipping 29 matching lines...) Expand all
213 # Check that the second event has addListener defined. 239 # Check that the second event has addListener defined.
214 self.assertEquals('noRules', dict_['events'][1]['name']) 240 self.assertEquals('noRules', dict_['events'][1]['name'])
215 self.assertEquals('add_rules_tester', dict_['name']) 241 self.assertEquals('add_rules_tester', dict_['name'])
216 self.assertEquals('noRules', dict_['events'][1]['name']) 242 self.assertEquals('noRules', dict_['events'][1]['name'])
217 self.assertEquals('callback', 243 self.assertEquals('callback',
218 dict_['events'][0]['byName']['addListener'][ 244 dict_['events'][0]['byName']['addListener'][
219 'parameters'][0]['name']) 245 'parameters'][0]['name'])
220 246
221 if __name__ == '__main__': 247 if __name__ == '__main__':
222 unittest.main() 248 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698