summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mailman/rest/tests/test_moderation.py36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/mailman/rest/tests/test_moderation.py b/src/mailman/rest/tests/test_moderation.py
index 46cc86d60..00eba3c22 100644
--- a/src/mailman/rest/tests/test_moderation.py
+++ b/src/mailman/rest/tests/test_moderation.py
@@ -60,13 +60,19 @@ Something else.
call_api('http://localhost:9001/3.0/lists/bee@example.com/held')
self.assertEqual(cm.exception.code, 404)
- def test_bad_request_id(self):
+ def test_bad_held_message_request_id(self):
# Bad request when request_id is not an integer.
with self.assertRaises(HTTPError) as cm:
call_api(
'http://localhost:9001/3.0/lists/ant@example.com/held/bogus')
self.assertEqual(cm.exception.code, 400)
+ def test_missing_held_message_request_id(self):
+ # Bad request when the request_id is not in the database.
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.0/lists/ant@example.com/held/99')
+ self.assertEqual(cm.exception.code, 404)
+
def test_subscription_request_as_held_message(self):
# Provide the request id of a subscription request using the held
# message API returns a not-found even though the request id is
@@ -84,7 +90,7 @@ Something else.
response, content = call_api(url.format(held_id))
self.assertEqual(response['message_id'], '<alpha>')
- def test_bad_action(self):
+ def test_bad_held_message_action(self):
# POSTing to a held message with a bad action.
held_id = hold_message(self._mlist, self._msg)
url = 'http://localhost:9001/3.0/lists/ant@example.com/held/{0}'
@@ -92,3 +98,29 @@ Something else.
call_api(url.format(held_id), {'action': 'bogus'})
self.assertEqual(cm.exception.code, 400)
self.assertEqual(cm.exception.msg, 'Cannot convert parameters: action')
+
+ def test_bad_subscription_request_id(self):
+ # Bad request when request_id is not an integer.
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.0/lists/ant@example.com/'
+ 'requests/bogus')
+ self.assertEqual(cm.exception.code, 400)
+
+ def test_missing_subscription_request_id(self):
+ # Bad request when the request_id is not in the database.
+ with self.assertRaises(HTTPError) as cm:
+ call_api('http://localhost:9001/3.0/lists/ant@example.com/'
+ 'requests/99')
+ self.assertEqual(cm.exception.code, 404)
+
+ def test_bad_subscription_action(self):
+ # POSTing to a held message with a bad action.
+ held_id = hold_subscription(
+ self._mlist, 'cperson@example.net', 'Cris Person', 'xyz',
+ DeliveryMode.regular, 'en')
+ config.db.store.commit()
+ url = 'http://localhost:9001/3.0/lists/ant@example.com/requests/{0}'
+ with self.assertRaises(HTTPError) as cm:
+ call_api(url.format(held_id), {'action': 'bogus'})
+ self.assertEqual(cm.exception.code, 400)
+ self.assertEqual(cm.exception.msg, 'Cannot convert parameters: action')