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

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: Adds test to api_data_source_test.py 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 },
156 { 'title': 'Permissions',
157 'content': [
158 { 'class': 'override',
159 'text': '"tester"'
160 },
161 { 'text': 'is an API for testing things.' }
162 ]
163 },
164 { 'title': 'Manifest',
165 'content': [
166 { 'class': 'code',
167 'text': '"tester": {...}'
168 }
169 ]
170 },
171 { 'title': 'Learn More',
172 'content': [
173 { 'link': 'https://tester.test.com/welcome.html',
174 'text': 'Welcome!'
175 }
176 ]
177 }
178 ]
179 self.assertEquals(model._GetIntroTableList(), expected_list)
180
181 model = _JSCModel(self._api_models.GetModel('tester').Get(),
182 _FakeScheduledAvailabilityFinder(),
183 self._json_cache,
184 _FakeTemplateCache(),
185 self._features_bundle,
186 None)
187 expected_list = [
jshumway 2014/04/25 21:34:43 Since only the second item in the list has changed
danielj41 2014/04/25 22:24:49 Done.
188 { 'title': 'Description',
189 'content': [
190 { 'text': 'a test api' }
191 ]
192 },
193 { 'title': 'Availability',
194 'content': [
195 { 'partial': 'handlebar chrome/common/extensions/docs/' +
196 'templates/private/intro_tables/dev_message.html',
197 'version': 28,
198 'scheduled': 28
199 }
200 ]
201 },
149 { 'title': 'Permissions', 202 { 'title': 'Permissions',
150 'content': [ 203 'content': [
151 { 'class': 'override', 204 { 'class': 'override',
152 'text': '"tester"' 205 'text': '"tester"'
153 }, 206 },
154 { 'text': 'is an API for testing things.' } 207 { 'text': 'is an API for testing things.' }
155 ] 208 ]
156 }, 209 },
157 { 'title': 'Manifest', 210 { 'title': 'Manifest',
158 'content': [ 211 'content': [
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 # Check that the second event has addListener defined. 266 # Check that the second event has addListener defined.
214 self.assertEquals('noRules', dict_['events'][1]['name']) 267 self.assertEquals('noRules', dict_['events'][1]['name'])
215 self.assertEquals('add_rules_tester', dict_['name']) 268 self.assertEquals('add_rules_tester', dict_['name'])
216 self.assertEquals('noRules', dict_['events'][1]['name']) 269 self.assertEquals('noRules', dict_['events'][1]['name'])
217 self.assertEquals('callback', 270 self.assertEquals('callback',
218 dict_['events'][0]['byName']['addListener'][ 271 dict_['events'][0]['byName']['addListener'][
219 'parameters'][0]['name']) 272 'parameters'][0]['name'])
220 273
221 if __name__ == '__main__': 274 if __name__ == '__main__':
222 unittest.main() 275 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698