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_cache import FileSystemCache | 10 from file_system_cache import FileSystemCache |
11 from local_file_system import LocalFileSystem | 11 from local_file_system import LocalFileSystem |
12 from api_data_source import APIDataSource | 12 from api_data_source import APIDataSource |
13 | 13 |
14 class APIDataSourceTest(unittest.TestCase): | 14 class APIDataSourceTest(unittest.TestCase): |
15 def setUp(self): | 15 def setUp(self): |
16 self._base_path = os.path.join('test_data', 'test_json') | 16 self._base_path = os.path.join('test_data', 'test_json') |
17 | 17 |
18 def _ReadLocalFile(self, filename): | 18 def _ReadLocalFile(self, filename): |
19 with open(os.path.join(self._base_path, filename), 'r') as f: | 19 with open(os.path.join(self._base_path, filename), 'r') as f: |
20 return f.read() | 20 return f.read() |
21 | 21 |
22 def testSimple(self): | 22 def testSimple(self): |
23 cache_builder = FileSystemCache.Builder(LocalFileSystem(self._base_path)) | 23 cache_builder = FileSystemCache.Builder(LocalFileSystem(self._base_path)) |
24 data_source = APIDataSource(cache_builder, './') | 24 data_source = APIDataSource(cache_builder, './') |
25 | 25 |
26 # Take the dict out of the list. | 26 # Take the dict out of the list. |
27 expected = json.loads(self._ReadLocalFile('expected_test_file.json')) | 27 expected = json.loads(self._ReadLocalFile('expected_test_file.json')) |
| 28 expected.update({ 'permissions': None }) |
28 self.assertEqual(expected, data_source['test_file']) | 29 self.assertEqual(expected, data_source['test_file']) |
29 self.assertEqual(expected, data_source['testFile']) | 30 self.assertEqual(expected, data_source['testFile']) |
30 self.assertEqual(expected, data_source['testFile.html']) | 31 self.assertEqual(expected, data_source['testFile.html']) |
31 | 32 |
32 self.assertEqual(None, data_source['junk']) | 33 self.assertEqual(None, data_source['junk']) |
33 | 34 |
34 if __name__ == '__main__': | 35 if __name__ == '__main__': |
35 unittest.main() | 36 unittest.main() |
OLD | NEW |