| 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 unittest | 8 import unittest |
| 9 | 9 |
| 10 from file_system import FileNotFoundError | 10 from file_system import FileNotFoundError |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 def testSimple(self): | 27 def testSimple(self): |
| 28 cache_builder = FileSystemCache.Builder(LocalFileSystem(self._base_path)) | 28 cache_builder = FileSystemCache.Builder(LocalFileSystem(self._base_path)) |
| 29 data_source_factory = APIDataSource.Factory(cache_builder, | 29 data_source_factory = APIDataSource.Factory(cache_builder, |
| 30 '.', | 30 '.', |
| 31 FakeSamplesDataSource()) | 31 FakeSamplesDataSource()) |
| 32 data_source = data_source_factory.Create({}) | 32 data_source = data_source_factory.Create({}) |
| 33 | 33 |
| 34 # Take the dict out of the list. | 34 # Take the dict out of the list. |
| 35 expected = json.loads(self._ReadLocalFile('expected_test_file.json')) | 35 expected = json.loads(self._ReadLocalFile('expected_test_file.json')) |
| 36 expected['permissions'] = None | 36 expected['permissions'] = None |
| 37 self.assertEqual(expected, data_source['test_file']) | 37 test1 = data_source['test_file'] |
| 38 self.assertEqual(expected, data_source['testFile']) | 38 test1.pop('samples') |
| 39 self.assertEqual(expected, data_source['testFile.html']) | 39 self.assertEqual(expected, test1) |
| 40 test2 = data_source['testFile'] |
| 41 test2.pop('samples') |
| 42 self.assertEqual(expected, test2) |
| 43 test3 = data_source['testFile.html'] |
| 44 test3.pop('samples') |
| 45 self.assertEqual(expected, test3) |
| 40 self.assertRaises(FileNotFoundError, data_source.get, 'junk') | 46 self.assertRaises(FileNotFoundError, data_source.get, 'junk') |
| 41 | 47 |
| 42 if __name__ == '__main__': | 48 if __name__ == '__main__': |
| 43 unittest.main() | 49 unittest.main() |
| OLD | NEW |