diff options
| author | Barry Warsaw | 2015-04-15 10:43:56 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2015-04-15 10:43:56 -0400 |
| commit | 21b6943debd12275a618301340508e2ba827a9c4 (patch) | |
| tree | 04c4ba70bde5213616fc8f7a3b78d0dc904fe58d /src/mailman/rest/tests/test_validator.py | |
| parent | 67fd8d6dbcf8849b3c2f8cb42a10aed465ace76c (diff) | |
| parent | cfbffa2ac1c5b6743705d3cc39d663eb642e7184 (diff) | |
| download | mailman-21b6943debd12275a618301340508e2ba827a9c4.tar.gz mailman-21b6943debd12275a618301340508e2ba827a9c4.tar.zst mailman-21b6943debd12275a618301340508e2ba827a9c4.zip | |
Diffstat (limited to 'src/mailman/rest/tests/test_validator.py')
| -rw-r--r-- | src/mailman/rest/tests/test_validator.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/mailman/rest/tests/test_validator.py b/src/mailman/rest/tests/test_validator.py new file mode 100644 index 000000000..c670fc77c --- /dev/null +++ b/src/mailman/rest/tests/test_validator.py @@ -0,0 +1,48 @@ +# Copyright (C) 2015 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. + +"""Test REST validators.""" + +__all__ = [ + 'TestValidators', + ] + + +import unittest + +from mailman.rest.validator import list_of_strings_validator +from mailman.testing.layers import RESTLayer + + + +class TestValidators(unittest.TestCase): + layer = RESTLayer + + def test_list_of_strings_validator_single(self): + # This validator should turn a single key into a list of keys. + self.assertEqual(list_of_strings_validator('ant'), ['ant']) + + def test_list_of_strings_validator_multiple(self): + # This validator should turn a single key into a list of keys. + self.assertEqual( + list_of_strings_validator(['ant', 'bee', 'cat']), + ['ant', 'bee', 'cat']) + + def test_list_of_strings_validator_invalid(self): + # Strings are required. + self.assertRaises(ValueError, list_of_strings_validator, 7) + self.assertRaises(ValueError, list_of_strings_validator, ['ant', 7]) |
