| OLD | NEW |
| 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 copy | 6 import copy |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 import unittest | 10 import unittest |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 def _ReadLocalFile(self, filename): | 54 def _ReadLocalFile(self, filename): |
| 55 with open(os.path.join(self._base_path, filename), 'r') as f: | 55 with open(os.path.join(self._base_path, filename), 'r') as f: |
| 56 return f.read() | 56 return f.read() |
| 57 | 57 |
| 58 def _CreateRefResolver(self, filename): | 58 def _CreateRefResolver(self, filename): |
| 59 data_source = FakeAPIAndListDataSource( | 59 data_source = FakeAPIAndListDataSource( |
| 60 self._LoadJSON(filename)) | 60 self._LoadJSON(filename)) |
| 61 return ReferenceResolver.Factory(data_source, | 61 return ReferenceResolver.Factory(data_source, |
| 62 data_source, | 62 data_source, |
| 63 ObjectStoreCreator.TestFactory()).Create() | 63 ObjectStoreCreator.ForTest()).Create() |
| 64 | 64 |
| 65 def _LoadJSON(self, filename): | 65 def _LoadJSON(self, filename): |
| 66 return json.loads(self._ReadLocalFile(filename)) | 66 return json.loads(self._ReadLocalFile(filename)) |
| 67 | 67 |
| 68 def testCreateId(self): | 68 def testCreateId(self): |
| 69 data_source = FakeAPIAndListDataSource( | 69 data_source = FakeAPIAndListDataSource( |
| 70 self._LoadJSON('test_file_data_source.json')) | 70 self._LoadJSON('test_file_data_source.json')) |
| 71 dict_ = _JSCModel(self._LoadJSON('test_file.json')[0], | 71 dict_ = _JSCModel(self._LoadJSON('test_file.json')[0], |
| 72 self._CreateRefResolver('test_file_data_source.json'), | 72 self._CreateRefResolver('test_file_data_source.json'), |
| 73 False).ToDict() | 73 False).ToDict() |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 ] | 173 ] |
| 174 } | 174 } |
| 175 | 175 |
| 176 inlined_schema = copy.deepcopy(schema) | 176 inlined_schema = copy.deepcopy(schema) |
| 177 _InlineDocs(inlined_schema) | 177 _InlineDocs(inlined_schema) |
| 178 self.assertEqual(expected_schema, inlined_schema) | 178 self.assertEqual(expected_schema, inlined_schema) |
| 179 | 179 |
| 180 | 180 |
| 181 if __name__ == '__main__': | 181 if __name__ == '__main__': |
| 182 unittest.main() | 182 unittest.main() |
| OLD | NEW |