| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 | 6 |
| 7 from components import config as config_component | 7 from components import config as config_component |
| 8 from components.config import validation_context | 8 from components.config import validation_context |
| 9 from testing_utils import testing | 9 from testing_utils import testing |
| 10 import mock | 10 import mock |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 ''') | 65 ''') |
| 66 | 66 |
| 67 | 67 |
| 68 class ConfigTest(testing.AppengineTestCase): | 68 class ConfigTest(testing.AppengineTestCase): |
| 69 def test_get_bucket_async(self): | 69 def test_get_bucket_async(self): |
| 70 config.Bucket( | 70 config.Bucket( |
| 71 id='master.tryserver.chromium.linux', | 71 id='master.tryserver.chromium.linux', |
| 72 project_id='chromium', | 72 project_id='chromium', |
| 73 revision='deadbeef', | 73 revision='deadbeef', |
| 74 config_content=MASTER_TRYSERVER_CHROMIUM_LINUX_CONFIG_TEXT).put() | 74 config_content=MASTER_TRYSERVER_CHROMIUM_LINUX_CONFIG_TEXT).put() |
| 75 cfg = config.get_bucket_async( | 75 project, cfg = config.get_bucket_async( |
| 76 'master.tryserver.chromium.linux').get_result() | 76 'master.tryserver.chromium.linux').get_result() |
| 77 self.assertEqual(project, 'chromium') |
| 77 self.assertEqual( | 78 self.assertEqual( |
| 78 cfg, | 79 cfg, |
| 79 project_config_pb2.Bucket( | 80 project_config_pb2.Bucket( |
| 80 name='master.tryserver.chromium.linux', | 81 name='master.tryserver.chromium.linux', |
| 81 acls=[ | 82 acls=[ |
| 82 project_config_pb2.Acl( | 83 project_config_pb2.Acl( |
| 83 role=project_config_pb2.Acl.READER, group='all'), | 84 role=project_config_pb2.Acl.READER, group='all'), |
| 84 project_config_pb2.Acl( | 85 project_config_pb2.Acl( |
| 85 role=project_config_pb2.Acl.SCHEDULER, group='tryjob-access'), | 86 role=project_config_pb2.Acl.SCHEDULER, group='tryjob-access'), |
| 86 ]), | 87 ]), |
| 87 ) | 88 ) |
| 88 | 89 |
| 89 self.assertIsNone(config.get_bucket_async('non.existing').get_result()) | 90 self.assertIsNone(config.get_bucket_async('non.existing').get_result()[0]) |
| 90 | 91 |
| 91 def test_get_buckets_async(self): | 92 def test_get_buckets_async(self): |
| 92 config.Bucket( | 93 config.Bucket( |
| 93 id='master.tryserver.chromium.linux', | 94 id='master.tryserver.chromium.linux', |
| 94 project_id='chromium', | 95 project_id='chromium', |
| 95 revision='deadbeef', | 96 revision='deadbeef', |
| 96 config_content=MASTER_TRYSERVER_CHROMIUM_LINUX_CONFIG_TEXT).put() | 97 config_content=MASTER_TRYSERVER_CHROMIUM_LINUX_CONFIG_TEXT).put() |
| 97 config.Bucket( | 98 config.Bucket( |
| 98 id='master.tryserver.chromium.win', | 99 id='master.tryserver.chromium.win', |
| 99 project_id='chromium', | 100 project_id='chromium', |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 445 |
| 445 url = config.get_buildbucket_cfg_url('chromium') | 446 url = config.get_buildbucket_cfg_url('chromium') |
| 446 self.assertEqual( | 447 self.assertEqual( |
| 447 url, | 448 url, |
| 448 ('https://chromium.googlesource.com/chromium/src/+/' | 449 ('https://chromium.googlesource.com/chromium/src/+/' |
| 449 'infra/config/testbed-test.cfg')) | 450 'infra/config/testbed-test.cfg')) |
| 450 | 451 |
| 451 | 452 |
| 452 def errmsg(text): | 453 def errmsg(text): |
| 453 return validation_context.Message(severity=logging.ERROR, text=text) | 454 return validation_context.Message(severity=logging.ERROR, text=text) |
| OLD | NEW |