OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The LUCI Authors. All rights reserved. | 2 # Copyright 2015 The LUCI Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
5 | 5 |
6 import datetime | 6 import datetime |
7 import logging | 7 import logging |
8 import sys | 8 import sys |
9 import unittest | 9 import unittest |
10 | 10 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 config.Revision('oauth_cfg_rev', 'http://url'), | 434 config.Revision('oauth_cfg_rev', 'http://url'), |
435 config_pb2.OAuthConfig(primary_client_id='a')), | 435 config_pb2.OAuthConfig(primary_client_id='a')), |
436 }, result) | 436 }, result) |
437 | 437 |
438 def test_fetch_configs_not_valid(self): | 438 def test_fetch_configs_not_valid(self): |
439 @ndb.tasklet | 439 @ndb.tasklet |
440 def get_self_config_mock(*_args, **_kwargs): | 440 def get_self_config_mock(*_args, **_kwargs): |
441 raise ndb.Return(('imports_cfg_rev', 'bad config')) | 441 raise ndb.Return(('imports_cfg_rev', 'bad config')) |
442 self.mock(config_component, 'get_self_config_async', get_self_config_mock) | 442 self.mock(config_component, 'get_self_config_async', get_self_config_mock) |
443 self.mock(config, '_get_configs_url', lambda: 'http://url') | 443 self.mock(config, '_get_configs_url', lambda: 'http://url') |
444 with self.assertRaises(config_component.CannotLoadConfigError): | 444 with self.assertRaises(config.CannotLoadConfigError): |
445 config._fetch_configs(['imports.cfg']) | 445 config._fetch_configs(['imports.cfg']) |
446 | 446 |
447 def test_gitiles_url(self): | 447 def test_gitiles_url(self): |
448 self.assertEqual( | 448 self.assertEqual( |
449 'https://host/repo/+/aaa/path/b/c.cfg', | 449 'https://host/repo/+/aaa/path/b/c.cfg', |
450 config._gitiles_url('https://host/repo/+/HEAD/path', 'aaa', 'b/c.cfg')) | 450 config._gitiles_url('https://host/repo/+/HEAD/path', 'aaa', 'b/c.cfg')) |
451 self.assertEqual( | 451 self.assertEqual( |
452 'https://not-gitiles', | 452 'https://not-gitiles', |
453 config._gitiles_url('https://not-gitiles', 'aaa', 'b/c.cfg')) | 453 config._gitiles_url('https://not-gitiles', 'aaa', 'b/c.cfg')) |
454 | 454 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 self.assertEqual(1, len(proto.rules)) | 603 self.assertEqual(1, len(proto.rules)) |
604 | 604 |
605 | 605 |
606 if __name__ == '__main__': | 606 if __name__ == '__main__': |
607 if '-v' in sys.argv: | 607 if '-v' in sys.argv: |
608 unittest.TestCase.maxDiff = None | 608 unittest.TestCase.maxDiff = None |
609 logging.basicConfig(level=logging.DEBUG) | 609 logging.basicConfig(level=logging.DEBUG) |
610 else: | 610 else: |
611 logging.basicConfig(level=logging.FATAL) | 611 logging.basicConfig(level=logging.FATAL) |
612 unittest.main() | 612 unittest.main() |
OLD | NEW |