Fix requirements of message_delete_many API

We must not require message_ids, as the message_delete_many API can be
called with pop_limit, and then needs to be called without message_ids.

Change-Id: Iefafc5029a639f2f60608af02e6de79a9fb4eddc
Closes-Bug: #1532837
This commit is contained in:
Thomas Herve 2016-01-11 16:47:33 +01:00
parent db3ef7fd97
commit 24933f089f
2 changed files with 21 additions and 1 deletions

View File

@ -294,7 +294,7 @@ class RequestSchema(api.Api):
'message_ids': {'type': 'array'},
'pop': {'type': 'integer'}
},
'required': ['queue_name', 'message_ids'],
'required': ['queue_name'],
}
},
'required': ['action', 'headers', 'body']

View File

@ -514,6 +514,26 @@ class MessagesBaseTest(base.V2Base):
resp = json.loads(send_mock.call_args[0][0])
self.assertEqual(204, resp['headers']['status'])
def test_pop_delete(self):
self._post_messages("kitkat", repeat=5)
action = "message_delete_many"
body = {"queue_name": "kitkat",
"pop_limit": 2}
send_mock = mock.Mock()
self.protocol.sendMessage = send_mock
req = test_utils.create_request(action, body, self.headers)
self.protocol.onMessage(req, False)
resp = json.loads(send_mock.call_args[0][0])
self.assertEqual(200, resp['headers']['status'])
self.assertEqual(2, len(resp['body']['messages']))
self.assertEqual(239, resp['body']['messages'][0]['body'])
self.assertEqual(239, resp['body']['messages'][1]['body'])
def test_get_nonexistent_message_404s(self):
action = "message_get"
body = {"queue_name": "notthere",