| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Swarming Authors. All rights reserved. | 2 # Copyright 2015 The Swarming Authors. All rights reserved. |
| 3 # Use of this source code is governed by the Apache v2.0 license that can be | 3 # Use of this source code is governed by the Apache v2.0 license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 from test_env import future | 6 from test_env import future |
| 7 import test_env | 7 import test_env |
| 8 test_env.setup_test_env() | 8 test_env.setup_test_env() |
| 9 | 9 |
| 10 from test_support import test_case | 10 from test_support import test_case |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 default_msg = service_config_pb2.ImportCfg( | 141 default_msg = service_config_pb2.ImportCfg( |
| 142 gitiles=service_config_pb2.ImportCfg.Gitiles(fetch_log_deadline=42)) | 142 gitiles=service_config_pb2.ImportCfg.Gitiles(fetch_log_deadline=42)) |
| 143 self.mock(storage, 'get_latest_async', mock.Mock()) | 143 self.mock(storage, 'get_latest_async', mock.Mock()) |
| 144 storage.get_latest_async.return_value = future( | 144 storage.get_latest_async.return_value = future( |
| 145 'gitiles { fetch_archive_deadline: 10 }') | 145 'gitiles { fetch_archive_deadline: 10 }') |
| 146 msg = storage.get_self_config_async( | 146 msg = storage.get_self_config_async( |
| 147 'import.cfg', lambda: default_msg).get_result() | 147 'import.cfg', lambda: default_msg).get_result() |
| 148 self.assertEqual(msg.gitiles.fetch_log_deadline, 42) | 148 self.assertEqual(msg.gitiles.fetch_log_deadline, 42) |
| 149 | 149 |
| 150 def test_get_self_config(self): | 150 def test_get_self_config(self): |
| 151 expected = service_config_pb2.AclCfg(service_access_group='group') | 151 expected = service_config_pb2.AclCfg(project_access_group='group') |
| 152 | 152 |
| 153 self.mock(storage, 'get_config_hash_async', mock.Mock()) | 153 self.mock(storage, 'get_config_hash_async', mock.Mock()) |
| 154 self.mock(storage, 'get_config_by_hash_async', mock.Mock()) | 154 self.mock(storage, 'get_config_by_hash_async', mock.Mock()) |
| 155 storage.get_config_hash_async.return_value = future( | 155 storage.get_config_hash_async.return_value = future( |
| 156 ('deadbeef', 'beefdead')) | 156 ('deadbeef', 'beefdead')) |
| 157 storage.get_config_by_hash_async.return_value = future( | 157 storage.get_config_by_hash_async.return_value = future( |
| 158 'service_access_group: "group"') | 158 'project_access_group: "group"') |
| 159 | 159 |
| 160 actual = storage.get_self_config_async( | 160 actual = storage.get_self_config_async( |
| 161 'acl.cfg', service_config_pb2.AclCfg).get_result() | 161 'acl.cfg', service_config_pb2.AclCfg).get_result() |
| 162 self.assertEqual(expected, actual) | 162 self.assertEqual(expected, actual) |
| 163 | 163 |
| 164 storage.get_config_hash_async.assert_called_once_with( | 164 storage.get_config_hash_async.assert_called_once_with( |
| 165 'services/sample-app', 'acl.cfg') | 165 'services/sample-app', 'acl.cfg') |
| 166 storage.get_config_by_hash_async.assert_called_once_with('beefdead') | 166 storage.get_config_by_hash_async.assert_called_once_with('beefdead') |
| 167 | 167 |
| 168 # memcached: | 168 # memcached: |
| 169 storage.get_config_hash_async.reset_mock() | 169 storage.get_config_hash_async.reset_mock() |
| 170 storage.get_config_by_hash_async.reset_mock() | 170 storage.get_config_by_hash_async.reset_mock() |
| 171 actual = storage.get_latest_as_message_async( | 171 actual = storage.get_latest_as_message_async( |
| 172 'services/sample-app', 'acl.cfg', | 172 'services/sample-app', 'acl.cfg', |
| 173 service_config_pb2.AclCfg).get_result() | 173 service_config_pb2.AclCfg).get_result() |
| 174 self.assertEqual(expected, actual) | 174 self.assertEqual(expected, actual) |
| 175 self.assertFalse(storage.get_config_hash_async.called) | 175 self.assertFalse(storage.get_config_hash_async.called) |
| 176 self.assertFalse(storage.get_config_by_hash_async.called) | 176 self.assertFalse(storage.get_config_by_hash_async.called) |
| 177 | 177 |
| 178 | 178 |
| 179 if __name__ == '__main__': | 179 if __name__ == '__main__': |
| 180 test_env.main() | 180 test_env.main() |
| OLD | NEW |