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 os | 6 import os |
7 import sys | 7 import sys |
8 import unittest | 8 import unittest |
9 | 9 |
10 import test_env | 10 import test_env |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 self.assertEqual([2, 3], prop.interpret([2, 3])) | 46 self.assertEqual([2, 3], prop.interpret([2, 3])) |
47 | 47 |
48 def testValidTypes(self): | 48 def testValidTypes(self): |
49 check = recipe_api.BoundProperty.legal_name | 49 check = recipe_api.BoundProperty.legal_name |
50 | 50 |
51 for test, result, is_param_name in ( | 51 for test, result, is_param_name in ( |
52 ('', False, False), | 52 ('', False, False), |
53 ('.', False, False), | 53 ('.', False, False), |
54 ('foo', True, False), | 54 ('foo', True, False), |
55 ('event.patchSet.ref', True, False), | 55 ('weird.param.name', True, False), |
56 ('event.patchSet.ref', False, True), | 56 ('weird.param.name', False, True), |
57 ('rietveld_url', True, False),): | 57 ('rietveld_url', True, False),): |
58 self.assertEqual( | 58 self.assertEqual( |
59 check(test, is_param_name=is_param_name), result, | 59 check(test, is_param_name=is_param_name), result, |
60 "name {} should be {}. is_param_name={}".format( | 60 "name {} should be {}. is_param_name={}".format( |
61 test, result, is_param_name)) | 61 test, result, is_param_name)) |
62 | 62 |
63 def testParamName(self): | 63 def testParamName(self): |
64 """Tests the default param name is the regular name.""" | 64 """Tests the default param name is the regular name.""" |
65 prop = recipe_api.Property() | 65 prop = recipe_api.Property() |
66 bound = prop.bind('a') | 66 bound = prop.bind('a') |
(...skipping 14 matching lines...) Expand all Loading... |
81 Tests setting a param name correctly carries through to a bound property. | 81 Tests setting a param name correctly carries through to a bound property. |
82 """ | 82 """ |
83 prop = recipe_api.Property(param_name='good_name') | 83 prop = recipe_api.Property(param_name='good_name') |
84 bound = prop.bind('bad.name-time', 'test', 'test_me') | 84 bound = prop.bind('bad.name-time', 'test', 'test_me') |
85 | 85 |
86 self.assertEqual('good_name', bound.param_name) | 86 self.assertEqual('good_name', bound.param_name) |
87 | 87 |
88 | 88 |
89 if __name__ == '__main__': | 89 if __name__ == '__main__': |
90 unittest.main() | 90 unittest.main() |
OLD | NEW |