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 json | 6 import json |
| 7 import unittest | 7 import unittest |
| 8 | 8 |
| 9 from api_models import APIModels | 9 from api_models import APIModels |
| 10 from compiled_file_system import CompiledFileSystem | 10 from compiled_file_system import CompiledFileSystem |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 self.assertRaises(FileNotFoundError, | 113 self.assertRaises(FileNotFoundError, |
| 114 self._api_models.GetModel(API + 'alarms.json').Get) | 114 self._api_models.GetModel(API + 'alarms.json').Get) |
| 115 self.assertRaises(FileNotFoundError, | 115 self.assertRaises(FileNotFoundError, |
| 116 self._api_models.GetModel('storage').Get) | 116 self._api_models.GetModel('storage').Get) |
| 117 self.assertRaises(FileNotFoundError, | 117 self.assertRaises(FileNotFoundError, |
| 118 self._api_models.GetModel(API + 'storage.json').Get) | 118 self._api_models.GetModel(API + 'storage.json').Get) |
| 119 self.assertRaises(FileNotFoundError, | 119 self.assertRaises(FileNotFoundError, |
| 120 self._api_models.GetModel(API + 'storage.idl').Get) | 120 self._api_models.GetModel(API + 'storage.idl').Get) |
| 121 | 121 |
| 122 def testSingleFile(self): | 122 def testSingleFile(self): |
| 123 # 2 stats (1 for JSON and 1 for IDL), 1 read (for IDL file which existed). | 123 # 2 stats (1 for JSON and 1 for IDL), 1 read (for IDL file which existed). |
|
not at google - send to devlin
2014/03/06 22:16:21
update this comment.
Ken Rockot(use gerrit already)
2014/03/06 23:55:16
Done.
| |
| 124 future = self._api_models.GetModel('alarms') | 124 future = self._api_models.GetModel('alarms') |
| 125 self.assertTrue(*self._mock_file_system.CheckAndReset( | 125 self.assertTrue(*self._mock_file_system.CheckAndReset( |
| 126 read_count=1, stat_count=2)) | 126 read_count=1, stat_count=4)) |
| 127 | 127 |
| 128 # 1 read-resolve (for the IDL file). | 128 # 1 read-resolve (for the IDL file). |
| 129 # | 129 # |
| 130 # The important part here and above is that it's only doing a single read; | 130 # The important part here and above is that it's only doing a single read; |
| 131 # any more would break the contract that only a single file is accessed - | 131 # any more would break the contract that only a single file is accessed - |
| 132 # see the SingleFile annotation in api_models._CreateAPIModel. | 132 # see the SingleFile annotation in api_models._CreateAPIModel. |
| 133 future.Get() | 133 future.Get() |
| 134 self.assertTrue(*self._mock_file_system.CheckAndReset( | 134 self.assertTrue(*self._mock_file_system.CheckAndReset( |
| 135 read_resolve_count=1)) | 135 read_resolve_count=1)) |
| 136 | 136 |
| 137 # 2 stats (1 for JSON and 1 for IDL), no reads (still cached). | 137 # 2 stats (1 for JSON and 1 for IDL), no reads (still cached). |
| 138 future = self._api_models.GetModel('alarms') | 138 future = self._api_models.GetModel('alarms') |
| 139 self.assertTrue(*self._mock_file_system.CheckAndReset(stat_count=2)) | 139 self.assertTrue(*self._mock_file_system.CheckAndReset(stat_count=4)) |
|
not at google - send to devlin
2014/03/06 22:16:21
and this one.
Ken Rockot(use gerrit already)
2014/03/06 23:55:16
Done.
| |
| 140 future.Get() | 140 future.Get() |
| 141 self.assertTrue(*self._mock_file_system.CheckAndReset()) | 141 self.assertTrue(*self._mock_file_system.CheckAndReset()) |
| 142 | 142 |
| 143 | 143 |
| 144 if __name__ == '__main__': | 144 if __name__ == '__main__': |
| 145 unittest.main() | 145 unittest.main() |
| OLD | NEW |