| OLD | NEW |
| 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_processor import SchemaProcessor | 9 from schema_processor import SchemaProcessor |
| 10 from future import Future | 10 from future import Future |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 ] | 121 ] |
| 122 | 122 |
| 123 object_store_creator = ObjectStoreCreator(start_empty=False) | 123 object_store_creator = ObjectStoreCreator(start_empty=False) |
| 124 host_file_system_provider = HostFileSystemProvider(object_store_creator) | 124 host_file_system_provider = HostFileSystemProvider(object_store_creator) |
| 125 schema_processor = SchemaProcessor(_FakeReferenceResolver(), | 125 schema_processor = SchemaProcessor(_FakeReferenceResolver(), |
| 126 _FakeAPIModels(), | 126 _FakeAPIModels(), |
| 127 _FakeFeaturesBundle(), | 127 _FakeFeaturesBundle(), |
| 128 CompiledFileSystem.Factory( | 128 CompiledFileSystem.Factory( |
| 129 object_store_creator), | 129 object_store_creator), |
| 130 host_file_system_provider.GetTrunk(), | 130 host_file_system_provider.GetMaster(), |
| 131 True) | 131 True) |
| 132 schema_processor._RemoveNoDocs(nodoc_data) | 132 schema_processor._RemoveNoDocs(nodoc_data) |
| 133 self.assertEquals(expected_nodoc, nodoc_data) | 133 self.assertEquals(expected_nodoc, nodoc_data) |
| 134 | 134 |
| 135 def testInlineDocs(self): | 135 def testInlineDocs(self): |
| 136 schema = { | 136 schema = { |
| 137 'namespace': 'storage', | 137 'namespace': 'storage', |
| 138 'properties': { | 138 'properties': { |
| 139 'key2': { | 139 'key2': { |
| 140 'description': 'second key', | 140 'description': 'second key', |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 ] | 192 ] |
| 193 } | 193 } |
| 194 | 194 |
| 195 object_store_creator = ObjectStoreCreator(start_empty=False) | 195 object_store_creator = ObjectStoreCreator(start_empty=False) |
| 196 host_file_system_provider = HostFileSystemProvider(object_store_creator) | 196 host_file_system_provider = HostFileSystemProvider(object_store_creator) |
| 197 schema_processor = SchemaProcessor(_FakeReferenceResolver(), | 197 schema_processor = SchemaProcessor(_FakeReferenceResolver(), |
| 198 _FakeAPIModels(), | 198 _FakeAPIModels(), |
| 199 _FakeFeaturesBundle(), | 199 _FakeFeaturesBundle(), |
| 200 CompiledFileSystem.Factory( | 200 CompiledFileSystem.Factory( |
| 201 object_store_creator), | 201 object_store_creator), |
| 202 host_file_system_provider.GetTrunk(), | 202 host_file_system_provider.GetMaster(), |
| 203 False) | 203 False) |
| 204 inlined_schema = deepcopy(schema) | 204 inlined_schema = deepcopy(schema) |
| 205 schema_processor._InlineDocs(inlined_schema) | 205 schema_processor._InlineDocs(inlined_schema) |
| 206 self.assertEqual(expected_schema, inlined_schema) | 206 self.assertEqual(expected_schema, inlined_schema) |
| 207 | 207 |
| 208 def testDetectInline(self): | 208 def testDetectInline(self): |
| 209 schema = { | 209 schema = { |
| 210 'types': [ | 210 'types': [ |
| 211 { | 211 { |
| 212 'id': 'Key', | 212 'id': 'Key', |
| (...skipping 19 matching lines...) Expand all Loading... |
| 232 ] | 232 ] |
| 233 } | 233 } |
| 234 | 234 |
| 235 object_store_creator = ObjectStoreCreator(start_empty=False) | 235 object_store_creator = ObjectStoreCreator(start_empty=False) |
| 236 host_file_system_provider = HostFileSystemProvider(object_store_creator) | 236 host_file_system_provider = HostFileSystemProvider(object_store_creator) |
| 237 schema_processor = SchemaProcessor(_FakeReferenceResolver(), | 237 schema_processor = SchemaProcessor(_FakeReferenceResolver(), |
| 238 _FakeAPIModels(), | 238 _FakeAPIModels(), |
| 239 _FakeFeaturesBundle(), | 239 _FakeFeaturesBundle(), |
| 240 CompiledFileSystem.Factory( | 240 CompiledFileSystem.Factory( |
| 241 object_store_creator), | 241 object_store_creator), |
| 242 host_file_system_provider.GetTrunk(), | 242 host_file_system_provider.GetMaster(), |
| 243 False) | 243 False) |
| 244 schema_processor._DetectInlineableTypes(schema) | 244 schema_processor._DetectInlineableTypes(schema) |
| 245 schema_processor._InlineDocs(schema) | 245 schema_processor._InlineDocs(schema) |
| 246 self.assertEqual(expected_schema, schema) | 246 self.assertEqual(expected_schema, schema) |
| 247 | 247 |
| 248 | 248 |
| 249 if __name__ == '__main__': | 249 if __name__ == '__main__': |
| 250 unittest.main() | 250 unittest.main() |
| OLD | NEW |