51
53
def test_get_request_with_type(self):
52
54
# get_request() takes an optional request type.
53
55
request_id = hold_message(self._mlist, self._msg)
54
requests_db = IListRequests(self._mlist)
55
56
# Submit a request with a non-matching type. This should return None
56
57
# as if there were no matches.
57
response = requests_db.get_request(
58
response = self._requests_db.get_request(
58
59
request_id, RequestType.subscription)
59
60
self.assertEqual(response, None)
60
61
# Submit the same request with a matching type.
61
key, data = requests_db.get_request(
62
key, data = self._requests_db.get_request(
62
63
request_id, RequestType.held_message)
63
64
self.assertEqual(key, '<alpha>')
64
65
# It should also succeed with no optional request type given.
65
key, data = requests_db.get_request(request_id)
66
key, data = self._requests_db.get_request(request_id)
66
67
self.assertEqual(key, '<alpha>')
69
def test_hold_with_bogus_type(self):
70
# Calling hold_request() with a bogus request type is an error.
71
with self.assertRaises(TypeError) as cm:
72
self._requests_db.hold_request(5, 'foo')
73
self.assertEqual(cm.exception.message, 5)
75
def test_delete_missing_request(self):
76
# Trying to delete a missing request is an error.
77
with self.assertRaises(KeyError) as cm:
78
self._requests_db.delete_request(801)
79
self.assertEqual(cm.exception.message, 801)