| 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 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 def setUp(self): | 50 def setUp(self): |
| 51 self._base_path = os.path.join(sys.path[0], 'test_data', 'test_json') | 51 self._base_path = os.path.join(sys.path[0], 'test_data', 'test_json') |
| 52 | 52 |
| 53 def _ReadLocalFile(self, filename): | 53 def _ReadLocalFile(self, filename): |
| 54 with open(os.path.join(self._base_path, filename), 'r') as f: | 54 with open(os.path.join(self._base_path, filename), 'r') as f: |
| 55 return f.read() | 55 return f.read() |
| 56 | 56 |
| 57 def _CreateRefResolver(self, filename): | 57 def _CreateRefResolver(self, filename): |
| 58 data_source = FakeAPIAndListDataSource( | 58 data_source = FakeAPIAndListDataSource( |
| 59 self._LoadJSON(filename)) | 59 self._LoadJSON(filename)) |
| 60 return ReferenceResolver.Factory(data_source, | 60 return ReferenceResolver.Factory(data_source, data_source).Create() |
| 61 data_source, | |
| 62 InMemoryObjectStore('')).Create() | |
| 63 | 61 |
| 64 def DISABLED_testSimple(self): | 62 def DISABLED_testSimple(self): |
| 65 cache_factory = CompiledFileSystem.Factory( | 63 compiled_fs_factory = CompiledFileSystem.Factory( |
| 66 LocalFileSystem(self._base_path), | 64 LocalFileSystem(self._base_path), |
| 67 InMemoryObjectStore('fake_branch')) | 65 InMemoryObjectStore('fake_branch')) |
| 68 data_source_factory = APIDataSource.Factory(cache_factory, | 66 data_source_factory = APIDataSource.Factory(compiled_fs_factory, |
| 69 '.') | 67 '.') |
| 70 data_source_factory.SetSamplesDataSourceFactory(FakeSamplesDataSource()) | 68 data_source_factory.SetSamplesDataSourceFactory(FakeSamplesDataSource()) |
| 71 data_source = data_source_factory.Create({}, disable_refs=True) | 69 data_source = data_source_factory.Create({}, disable_refs=True) |
| 72 | 70 |
| 73 # Take the dict out of the list. | 71 # Take the dict out of the list. |
| 74 expected = json.loads(self._ReadLocalFile('expected_test_file.json')) | 72 expected = json.loads(self._ReadLocalFile('expected_test_file.json')) |
| 75 expected['permissions'] = None | 73 expected['permissions'] = None |
| 76 test1 = data_source.get('test_file') | 74 test1 = data_source.get('test_file') |
| 77 test1.pop('samples') | 75 test1.pop('samples') |
| 78 self.assertEqual(expected, test1) | 76 self.assertEqual(expected, test1) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 _MakeLink('ref_test.html#type-type2', 'type2')), | 128 _MakeLink('ref_test.html#type-type2', 'type2')), |
| 131 _GetType(dict_, 'type3')['description']) | 129 _GetType(dict_, 'type3')['description']) |
| 132 | 130 |
| 133 def testRemoveNoDocs(self): | 131 def testRemoveNoDocs(self): |
| 134 d = self._LoadJSON('nodoc_test.json') | 132 d = self._LoadJSON('nodoc_test.json') |
| 135 _RemoveNoDocs(d) | 133 _RemoveNoDocs(d) |
| 136 self.assertEqual(self._LoadJSON('expected_nodoc.json'), d) | 134 self.assertEqual(self._LoadJSON('expected_nodoc.json'), d) |
| 137 | 135 |
| 138 if __name__ == '__main__': | 136 if __name__ == '__main__': |
| 139 unittest.main() | 137 unittest.main() |
| OLD | NEW |