| OLD | NEW |
| (Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The LUCI 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 import logging |
| 7 import sys |
| 8 import unittest |
| 9 |
| 10 import test_env |
| 11 test_env.setup_test_env() |
| 12 |
| 13 from components.config import validation |
| 14 from test_support import test_case |
| 15 |
| 16 from proto import config_pb2 |
| 17 from server import config |
| 18 |
| 19 |
| 20 # pylint: disable=W0212,W0612 |
| 21 |
| 22 |
| 23 class ConfigTest(test_case.TestCase): |
| 24 def test_validate_isolate_settings(self): |
| 25 def validate(**cfg): |
| 26 cfg = config_pb2.IsolateSettings(**cfg) |
| 27 ctx = validation.Context.raise_on_error() |
| 28 config.validate_isolate_settings(cfg, ctx) |
| 29 |
| 30 with self.assertRaises(ValueError): |
| 31 validate(default_server_host='isolateserver.appspot.com') |
| 32 with self.assertRaises(ValueError): |
| 33 validate( |
| 34 default_server_host='https://isolateserver.appspot.com', |
| 35 default_namespace='abc' |
| 36 ) |
| 37 validate() |
| 38 |
| 39 def test_validate_settings(self): |
| 40 def validate(**cfg): |
| 41 cfg = config_pb2.SettingsCfg(**cfg) |
| 42 ctx = validation.Context.raise_on_error() |
| 43 config.validate_settings(cfg, ctx) |
| 44 |
| 45 with self.assertRaises(ValueError): |
| 46 validate(bot_death_timeout_secs=-1) |
| 47 with self.assertRaises(ValueError): |
| 48 validate(bot_death_timeout_secs=config.SECONDS_IN_YEAR + 1) |
| 49 with self.assertRaises(ValueError): |
| 50 validate(reusable_task_age_secs=-1) |
| 51 with self.assertRaises(ValueError): |
| 52 validate(reusable_task_age_secs=config.SECONDS_IN_YEAR + 1) |
| 53 validate() |
| 54 |
| 55 |
| 56 if __name__ == '__main__': |
| 57 if '-v' in sys.argv: |
| 58 unittest.TestCase.maxDiff = None |
| 59 logging.basicConfig( |
| 60 level=logging.DEBUG if '-v' in sys.argv else logging.CRITICAL) |
| 61 unittest.main() |
| OLD | NEW |