summaryrefslogtreecommitdiff
path: root/src/mailman/rest/tests/test_validator.py
diff options
context:
space:
mode:
authorBarry Warsaw2015-12-30 14:34:18 -0500
committerBarry Warsaw2015-12-30 14:38:10 -0500
commitdac929973fbfc7ac4c807afafc22b992510b4e6d (patch)
tree7deb45c8500cf099215fce8e61055b7e1242fb57 /src/mailman/rest/tests/test_validator.py
parent8e69b848270da6ba4852f8c6dfdeeed8124ab024 (diff)
downloadmailman-dac929973fbfc7ac4c807afafc22b992510b4e6d.tar.gz
mailman-dac929973fbfc7ac4c807afafc22b992510b4e6d.tar.zst
mailman-dac929973fbfc7ac4c807afafc22b992510b4e6d.zip
Major push for completing issue #121. Now in API 3.1, all UUIDs must be the
hex representations of a UUID, not the int representation. Also: * Some general code cleanup. * Fix issue 185 (REST server crash when subscribing a user without a preferred address).
Diffstat (limited to 'src/mailman/rest/tests/test_validator.py')
-rw-r--r--src/mailman/rest/tests/test_validator.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/mailman/rest/tests/test_validator.py b/src/mailman/rest/tests/test_validator.py
index 2d515f828..030fd7aa9 100644
--- a/src/mailman/rest/tests/test_validator.py
+++ b/src/mailman/rest/tests/test_validator.py
@@ -50,15 +50,38 @@ class TestValidators(unittest.TestCase):
self.assertRaises(ValueError, list_of_strings_validator, 7)
self.assertRaises(ValueError, list_of_strings_validator, ['ant', 7])
- def test_subscriber_validator_uuid(self):
+ def test_subscriber_validator_int_uuid(self):
# Convert from an existing user id to a UUID.
anne = getUtility(IUserManager).make_user('anne@example.com')
- uuid = subscriber_validator(str(anne.user_id.int))
+ uuid = subscriber_validator('3.0')(str(anne.user_id.int))
self.assertEqual(anne.user_id, uuid)
- def test_subscriber_validator_bad_uuid(self):
- self.assertRaises(ValueError, subscriber_validator, 'not-a-thing')
+ def test_subscriber_validator_hex_uuid(self):
+ # Convert from an existing user id to a UUID.
+ anne = getUtility(IUserManager).make_user('anne@example.com')
+ uuid = subscriber_validator('3.1')(anne.user_id.hex)
+ self.assertEqual(anne.user_id, uuid)
+
+ def test_subscriber_validator_no_int_uuid(self):
+ # API 3.1 does not accept ints as subscriber id's.
+ anne = getUtility(IUserManager).make_user('anne@example.com')
+ self.assertRaises(ValueError,
+ subscriber_validator('3.1'), str(anne.user_id.int))
+
+ def test_subscriber_validator_bad_int_uuid(self):
+ # In API 3.0, UUIDs are ints.
+ self.assertRaises(ValueError,
+ subscriber_validator('3.0'), 'not-a-thing')
+
+ def test_subscriber_validator_bad_int_hex(self):
+ # In API 3.1, UUIDs are hexes.
+ self.assertRaises(ValueError,
+ subscriber_validator('3.1'), 'not-a-thing')
+
+ def test_subscriber_validator_email_address_API30(self):
+ self.assertEqual(subscriber_validator('3.0')('anne@example.com'),
+ 'anne@example.com')
- def test_subscriber_validator_email_address(self):
- self.assertEqual(subscriber_validator('anne@example.com'),
+ def test_subscriber_validator_email_address_API31(self):
+ self.assertEqual(subscriber_validator('3.1')('anne@example.com'),
'anne@example.com')