diff --git a/tests/unit/queues/v1/test_core.py b/tests/unit/queues/v1/test_core.py index 7919fa54..fff515ee 100644 --- a/tests/unit/queues/v1/test_core.py +++ b/tests/unit/queues/v1/test_core.py @@ -98,8 +98,25 @@ class TestV1Core(base.TestBase): result = core.queue_get_stats(self.transport, req, 'test') self.assertEqual(result, {}) - def test_message_post(self): - messages = [{'ttl': 30, 'body': 'Post It!'}] + def test_message_post_one(self): + messages = {'ttl': 30, 'body': 'Post one!'} + + with mock.patch.object(self.transport, 'send', + autospec=True) as send_method: + resp = response.Response(None, '{}') + send_method.return_value = resp + + req = request.Request() + + core.message_post(self.transport, req, 'test', messages) + self.assertIn('queue_name', req.params) + self.assertEqual(json.loads(req.content), + messages) + + def test_message_post_many(self): + messages = [{'ttl': 30, 'body': 'Post one!'}, + {'ttl': 30, 'body': 'Post two!'}, + {'ttl': 30, 'body': 'Post three!'}, ] with mock.patch.object(self.transport, 'send', autospec=True) as send_method: diff --git a/zaqarclient/queues/v1/queues.py b/zaqarclient/queues/v1/queues.py index 367febc4..64e04b33 100644 --- a/zaqarclient/queues/v1/queues.py +++ b/zaqarclient/queues/v1/queues.py @@ -108,6 +108,9 @@ class Queue(object): if not isinstance(messages, list): messages = [messages] + if self.client.api_version >= 1.1: + messages = {'messages': messages} + req, trans = self.client._request_and_transport() # TODO(flaper87): Return a list of messages