Allow passing in multiple tag names to the validation decorator.

We have problems when we try to wrap one decorator around another.
There are ways to do that with the
[decorator](https://pypi.python.org/pypi/decorator) module nicely,
however.. they are ugly.

Take a look at this:

https://github.com/micheles/decorator/blob/master/src/decorator.py#L217-L218

And this:

https://github.com/micheles/decorator/blob/master/src/decorator.py#L185-L188

The approach in this PR is.. simpler.
This commit is contained in:
Ralph Bean
2017-02-28 17:15:55 -05:00
parent 6dd223fd12
commit ca61d6bb29
3 changed files with 70 additions and 27 deletions

View File

@@ -233,3 +233,25 @@ class TestUtils(unittest.TestCase):
self.assertEquals(
validate_koji_tag_good_tag_value_in_dict_nondefault_key(
{'nondefault': 'module-foo'}), True)
def test_validate_koji_tag_double_trouble_good(self):
""" Test that we pass on a list of tags that are good. """
expected = 'foo'
@module_build_service.utils.validate_koji_tag(['tag_arg1', 'tag_arg2'])
def validate_koji_tag_double_trouble(tag_arg1, tag_arg2):
return expected
actual = validate_koji_tag_double_trouble('module-1', 'module-2')
self.assertEquals(actual, expected)
def test_validate_koji_tag_double_trouble_bad(self):
""" Test that we fail on a list of tags that are bad. """
@module_build_service.utils.validate_koji_tag(['tag_arg1', 'tag_arg2'])
def validate_koji_tag_double_trouble(tag_arg1, tag_arg2):
pass
with self.assertRaises(ValidationError):
validate_koji_tag_double_trouble('module-1', 'BADNEWS-2')