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

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

Issue 532423002: Inlining references to internal APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing extensionTypes from chrome api features (still in extension api features) Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 unittest 6 import unittest
7 from copy import deepcopy 7 from copy import deepcopy
8 8
9 from schema_util import RemoveNoDocs, DetectInlineableTypes, InlineDocs 9 from process_schema import ProcessSchema
10 from future import Future
11 from object_store_creator import ObjectStoreCreator
12 from host_file_system_provider import HostFileSystemProvider
13 from compiled_file_system import CompiledFileSystem
10 14
15 class _FakeReferenceResolver():
16 def GetRefModel(self, ref, api_list):
17 return None, None
18
19 class _FakeAPIModels():
20 def GetNames(self):
21 return []
22
23 class _FakeFeaturesBundle():
24 def GetAPIFeatures(self):
25 return Future(value={})
11 26
12 class SchemaUtilTest(unittest.TestCase): 27 class SchemaUtilTest(unittest.TestCase):
13
14 def testRemoveNoDocs(self): 28 def testRemoveNoDocs(self):
15 expected_nodoc = [ 29 expected_nodoc = [
16 { 30 {
17 'name': 'B', 31 'name': 'B',
18 'list': [ 32 'list': [
19 { 33 {
20 'name': 'B2' 34 'name': 'B2'
21 } 35 }
22 ] 36 ]
23 }, 37 },
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 'name': 'E2' 113 'name': 'E2'
100 }, 114 },
101 { 115 {
102 'name': 'E3', 116 'name': 'E3',
103 'nodoc': True 117 'nodoc': True
104 } 118 }
105 ] 119 ]
106 } 120 }
107 ] 121 ]
108 122
109 RemoveNoDocs(nodoc_data) 123 object_store_creator = ObjectStoreCreator(start_empty=False)
124 host_file_system_provider = HostFileSystemProvider(object_store_creator)
125 process_schema = ProcessSchema(_FakeReferenceResolver(),
126 _FakeAPIModels(),
127 _FakeFeaturesBundle(),
128 CompiledFileSystem.Factory(
129 object_store_creator),
130 host_file_system_provider.GetTrunk(),
131 True)
132 process_schema._RemoveNoDocs(nodoc_data)
110 self.assertEquals(expected_nodoc, nodoc_data) 133 self.assertEquals(expected_nodoc, nodoc_data)
111 134
112 def testInlineDocs(self): 135 def testInlineDocs(self):
113 schema = { 136 schema = {
114 'namespace': 'storage', 137 'namespace': 'storage',
115 'properties': { 138 'properties': {
116 'key2': { 139 'key2': {
117 'description': 'second key', 140 'description': 'second key',
118 '$ref': 'Key' 141 '$ref': 'Key'
119 }, 142 },
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 'marker': True, 185 'marker': True,
163 'type': 'string' 186 'type': 'string'
164 }, 187 },
165 'type': 'array', 188 'type': 'array',
166 'id': 'KeyList', 189 'id': 'KeyList',
167 'description': 'A list of keys' 190 'description': 'A list of keys'
168 } 191 }
169 ] 192 ]
170 } 193 }
171 194
195 object_store_creator = ObjectStoreCreator(start_empty=False)
196 host_file_system_provider = HostFileSystemProvider(object_store_creator)
197 process_schema = ProcessSchema(_FakeReferenceResolver(),
198 _FakeAPIModels(),
199 _FakeFeaturesBundle(),
200 CompiledFileSystem.Factory(
201 object_store_creator),
202 host_file_system_provider.GetTrunk(),
203 False)
172 inlined_schema = deepcopy(schema) 204 inlined_schema = deepcopy(schema)
173 InlineDocs(inlined_schema, False) 205 process_schema._InlineDocs(inlined_schema)
174 self.assertEqual(expected_schema, inlined_schema) 206 self.assertEqual(expected_schema, inlined_schema)
175 207
176 def testDetectInline(self): 208 def testDetectInline(self):
177 schema = { 209 schema = {
178 'types': [ 210 'types': [
179 { 211 {
180 'id': 'Key', 212 'id': 'Key',
181 'items': { 213 'items': {
182 '$ref': 'Value' 214 '$ref': 'Value'
183 } 215 }
184 }, 216 },
185 { 217 {
186 'id': 'Value', 218 'id': 'Value',
187 'marker': True 219 'marker': True
188 } 220 }
189 ] 221 ]
190 } 222 }
191 223
192 expected_schema = { 224 expected_schema = {
193 'types': [ 225 'types': [
194 { 226 {
195 'id': 'Key', 227 'id': 'Key',
196 'items': { 228 'items': {
197 'marker': True, 229 'marker': True,
198 } 230 }
199 } 231 }
200 ] 232 ]
201 } 233 }
202 234
203 DetectInlineableTypes(schema) 235 object_store_creator = ObjectStoreCreator(start_empty=False)
204 InlineDocs(schema, False) 236 host_file_system_provider = HostFileSystemProvider(object_store_creator)
237 process_schema = ProcessSchema(_FakeReferenceResolver(),
238 _FakeAPIModels(),
239 _FakeFeaturesBundle(),
240 CompiledFileSystem.Factory(
241 object_store_creator),
242 host_file_system_provider.GetTrunk(),
243 False)
244 process_schema._DetectInlineableTypes(schema)
245 process_schema._InlineDocs(schema)
205 self.assertEqual(expected_schema, schema) 246 self.assertEqual(expected_schema, schema)
206 247
207 248
208 if __name__ == '__main__': 249 if __name__ == '__main__':
209 unittest.main() 250 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698