Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 functools | 6 import functools |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 from compiled_file_system import CompiledFileSystem | 9 from compiled_file_system import CompiledFileSystem |
| 10 from copy import deepcopy | 10 from copy import deepcopy |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 self.assertTrue(*mock_fs.CheckAndReset()) | 193 self.assertTrue(*mock_fs.CheckAndReset()) |
| 194 | 194 |
| 195 # Similar configuration to the 'apps/' case but deeper. | 195 # Similar configuration to the 'apps/' case but deeper. |
| 196 future = compiled_fs.GetFromFileListing('') | 196 future = compiled_fs.GetFromFileListing('') |
| 197 self.assertTrue(*mock_fs.CheckAndReset(stat_count=1, | 197 self.assertTrue(*mock_fs.CheckAndReset(stat_count=1, |
| 198 read_count=2, | 198 read_count=2, |
| 199 read_resolve_count=1)) | 199 read_resolve_count=1)) |
| 200 future.Get() | 200 future.Get() |
| 201 self.assertTrue(*mock_fs.CheckAndReset(read_count=2, read_resolve_count=3)) | 201 self.assertTrue(*mock_fs.CheckAndReset(read_count=2, read_resolve_count=3)) |
| 202 | 202 |
| 203 def testSkipNotFound(self): | |
| 204 mock_fs = MockFileSystem(TestFileSystem(_TEST_DATA)) | |
| 205 compiled_fs = CompiledFileSystem.Factory( | |
| 206 ObjectStoreCreator.ForTest()).Create( | |
| 207 mock_fs, lambda path, contents: contents, type(self)) | |
| 208 | |
| 209 future = compiled_fs.GetFromFile('no_file', skip_not_found=True) | |
| 210 # If the file doesn't exist, then the file system is not read. | |
| 211 self.assertTrue(*mock_fs.CheckAndReset(read_count=1, stat_count=1)) | |
| 212 self.assertEqual(None, future.Get()) | |
| 213 self.assertTrue(*mock_fs.CheckAndReset(read_resolve_count=1)) | |
| 214 future = compiled_fs.GetFromFile('no_file', skip_not_found=True) | |
| 215 self.assertTrue(*mock_fs.CheckAndReset(stat_count=1)) | |
| 216 self.assertEqual(None, future.Get()) | |
| 217 # The result for a non-existent file should still be cached. | |
| 218 self.assertTrue(*mock_fs.CheckAndReset()) | |
| 219 future = compiled_fs.GetFromFile('no_file') | |
| 220 self.assertRaises(FileNotFoundError, future.Get) | |
|
not at google - send to devlin
2014/08/26 20:59:34
Same comment in the other test, if possible.
| |
| 203 | 221 |
| 204 | 222 |
| 205 if __name__ == '__main__': | 223 if __name__ == '__main__': |
| 206 unittest.main() | 224 unittest.main() |
| OLD | NEW |