def test_unsubscribe_defer(self): # When unsubscriptions must be approved by the moderator, but the # moderator defers this decision. token = hold_subscription( self._mlist, RequestRecord('*****@*****.**', 'Anne Person', DeliveryMode.regular, 'en')) handle_subscription(self._mlist, token, Action.accept) # Now hold and handle an unsubscription request. token = hold_unsubscription(self._mlist, '*****@*****.**') handle_unsubscription(self._mlist, token, Action.defer)
def test_bad_subscription_action(self): # POSTing to a held message with a bad action. held_id = hold_subscription( self._mlist, "*****@*****.**", "Cris Person", "xyz", DeliveryMode.regular, "en" ) config.db.store.commit() url = "http://*****:*****@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")
def test_bad_subscription_action(self): # POSTing to a held message with a bad action. held_id = hold_subscription(self._mlist, '*****@*****.**', 'Cris Person', 'xyz', DeliveryMode.regular, 'en') config.db.store.commit() url = 'http://*****:*****@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, b'Cannot convert parameters: action')
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 # in the database. held_id = hold_message(self._mlist, self._msg) subscribe_id = hold_subscription( self._mlist, "*****@*****.**", "Bart Person", "xyz", DeliveryMode.regular, "en" ) config.db.store.commit() url = "http://*****:*****@example.com/held/{0}" with self.assertRaises(HTTPError) as cm: call_api(url.format(subscribe_id)) self.assertEqual(cm.exception.code, 404) # But using the held_id returns a valid response. response, content = call_api(url.format(held_id)) self.assertEqual(response["message_id"], "<alpha>")
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 # in the database. held_id = hold_message(self._mlist, self._msg) subscribe_id = hold_subscription(self._mlist, '*****@*****.**', 'Bart Person', 'xyz', DeliveryMode.regular, 'en') config.db.store.commit() url = 'http://*****:*****@example.com/held/{0}' with self.assertRaises(HTTPError) as cm: call_api(url.format(subscribe_id)) self.assertEqual(cm.exception.code, 404) # But using the held_id returns a valid response. response, content = call_api(url.format(held_id)) self.assertEqual(response['message_id'], '<alpha>')