diff options
| author | Barry Warsaw | 2015-04-06 21:39:34 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2015-04-06 21:39:34 -0400 |
| commit | a499404b568b303697b1969d8766f7f8433b76a7 (patch) | |
| tree | dc410aa3a1179d8509a58f2978a89943f3664d08 /src/mailman/rest/validator.py | |
| parent | 20edc89f208b201e34628cc021c5bfe36ef5a035 (diff) | |
| download | mailman-a499404b568b303697b1969d8766f7f8433b76a7.tar.gz mailman-a499404b568b303697b1969d8766f7f8433b76a7.tar.zst mailman-a499404b568b303697b1969d8766f7f8433b76a7.zip | |
Add lots of test for various bits of domain owners.
A little refactoring of list_of_str() into list_of_strings_validator() which
is now put in the validators.py module and used in several places.
Python 3 super() style.
Add some code and tests to catch <domain>/owners references when <domain>
doesn't exist.
Diffstat (limited to 'src/mailman/rest/validator.py')
| -rw-r--r-- | src/mailman/rest/validator.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mailman/rest/validator.py b/src/mailman/rest/validator.py index 867991a36..d09886e36 100644 --- a/src/mailman/rest/validator.py +++ b/src/mailman/rest/validator.py @@ -22,6 +22,7 @@ __all__ = [ 'Validator', 'enum_validator', 'language_validator', + 'list_of_strings_validator', 'subscriber_validator', ] @@ -66,6 +67,14 @@ def language_validator(code): return getUtility(ILanguageManager)[code] +def list_of_strings_validator(values): + """Turn a list of things into a list of unicodes.""" + for value in values: + if not isinstance(value, str): + raise ValueError('Expected str, got {!r}'.format(value)) + return values + + class Validator: """A validator of parameter input.""" |
