OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 from test_env import future |
| 7 import test_env |
| 8 test_env.setup_test_env() |
| 9 |
| 10 import mock |
| 11 from test_support import test_case |
| 12 |
| 13 from proto import service_config_pb2 |
| 14 import services |
| 15 import storage |
| 16 |
| 17 |
| 18 class ProjectsTestCase(test_case.TestCase): |
| 19 def test_dict_to_dynamic_metadata(self): |
| 20 with self.assertRaises(services.DynamicMetadataError): |
| 21 services._dict_to_dynamic_metadata([]) |
| 22 |
| 23 self.assertEqual( |
| 24 services._dict_to_dynamic_metadata({ |
| 25 'validation': { |
| 26 'url': 'https://a.com/validate', |
| 27 'patterns': [ |
| 28 {'config_set': 'projects/foo', 'path': 'bar.cfg'}, |
| 29 {'config_set': 'regex:services/.+', 'path': 'regex:.+'}, |
| 30 ] |
| 31 } |
| 32 }), |
| 33 service_config_pb2.ServiceDynamicMetadata( |
| 34 validation=service_config_pb2.Validator( |
| 35 url='https://a.com/validate', |
| 36 patterns=[ |
| 37 service_config_pb2.ConfigPattern( |
| 38 config_set='projects/foo', path='bar.cfg'), |
| 39 service_config_pb2.ConfigPattern( |
| 40 config_set='regex:services/.+', path='regex:.+'), |
| 41 ] |
| 42 ) |
| 43 ) |
| 44 ) |
| 45 |
| 46 |
| 47 if __name__ == '__main__': |
| 48 test_env.main() |
OLD | NEW |