Chromium Code Reviews| 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 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 def testSimple(self): | 26 def testSimple(self): |
| 27 cache_builder = FileSystemCache.Builder(LocalFileSystem(self._base_path)) | 27 cache_builder = FileSystemCache.Builder(LocalFileSystem(self._base_path)) |
| 28 data_source_factory = APIDataSource.Factory(cache_builder, | 28 data_source_factory = APIDataSource.Factory(cache_builder, |
| 29 './', | 29 './', |
| 30 FakeSamplesDataSource()) | 30 FakeSamplesDataSource()) |
| 31 data_source = data_source_factory.Create({}) | 31 data_source = data_source_factory.Create({}) |
| 32 | 32 |
| 33 # Take the dict out of the list. | 33 # Take the dict out of the list. |
| 34 expected = json.loads(self._ReadLocalFile('expected_test_file.json')) | 34 expected = json.loads(self._ReadLocalFile('expected_test_file.json')) |
| 35 expected['permissions'] = None | 35 expected['permissions'] = None |
| 36 self.assertEqual(expected, data_source['test_file']) | 36 test1 = data_source['test_file'] |
| 37 self.assertEqual(expected, data_source['testFile']) | 37 test1.pop('samples') |
|
not at google - send to devlin
2012/08/10 06:02:18
Why not just add the samples to the expected data?
cduvall
2012/08/10 21:17:47
The samples isn't actually a SamplesDataSource, it
not at google - send to devlin
2012/08/13 01:51:11
Ah I see.
Could you define __eq__ for Future, whi
not at google - send to devlin
2012/08/13 22:39:09
(sorry about this comment, my brain did s/_LazySam
| |
| 38 self.assertEqual(expected, data_source['testFile.html']) | 38 self.assertEqual(expected, test1) |
| 39 test2 = data_source['testFile'] | |
| 40 test2.pop('samples') | |
| 41 self.assertEqual(expected, test2) | |
| 42 test3 = data_source['testFile.html'] | |
| 43 test3.pop('samples') | |
| 44 self.assertEqual(expected, test3) | |
| 39 self.assertRaises(OSError, data_source.get, 'junk') | 45 self.assertRaises(OSError, data_source.get, 'junk') |
| 40 | 46 |
| 41 if __name__ == '__main__': | 47 if __name__ == '__main__': |
| 42 unittest.main() | 48 unittest.main() |
| OLD | NEW |