From 66537dd067a6cf5c43597a7c31625be0ce145a83 Mon Sep 17 00:00:00 2001 From: gengchc2 Date: Wed, 15 Nov 2017 01:03:28 -0800 Subject: [PATCH] Missing claim_count in mongodb MessageController _basic_message Missing claim_count in mongodb MessageController _basic_message, When MessageController.get is executed, the result returned is different from redis and swift. Change-Id: Ieb01e0fa09f613e8871ec7fa381fbda6efc57e96 --- zaqar/storage/mongodb/messages.py | 1 + zaqar/tests/unit/storage/base.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/zaqar/storage/mongodb/messages.py b/zaqar/storage/mongodb/messages.py index 176c6c697..707505c13 100644 --- a/zaqar/storage/mongodb/messages.py +++ b/zaqar/storage/mongodb/messages.py @@ -984,6 +984,7 @@ def _basic_message(msg, now): 'id': str(oid), 'age': int(age), 'ttl': msg['t'], + 'claim_count': msg['c'].get('c', 0), 'body': msg['b'], 'claim_id': str(msg['c']['id']) if msg['c']['id'] else None } diff --git a/zaqar/tests/unit/storage/base.py b/zaqar/tests/unit/storage/base.py index da5df9d95..60d5f3204 100644 --- a/zaqar/tests/unit/storage/base.py +++ b/zaqar/tests/unit/storage/base.py @@ -433,8 +433,8 @@ class MessageControllerTest(ControllerBaseTest): # Test Message Get message_out = self.controller.get(queue_name, message_id, project=self.project) - self.assertEqual({'id', 'body', 'ttl', 'age', 'claim_id'}, - set(message_out)) + self.assertEqual({'id', 'body', 'ttl', 'age', 'claim_count', + 'claim_id'}, set(message_out)) self.assertEqual(message_id, message_out['id']) self.assertEqual(message['body'], message_out['body']) self.assertEqual(message['ttl'], message_out['ttl']) @@ -489,8 +489,8 @@ class MessageControllerTest(ControllerBaseTest): project=self.project) for idx, message in enumerate(messages_out): - self.assertEqual({'id', 'body', 'ttl', 'age', 'claim_id'}, - set(message)) + self.assertEqual({'id', 'body', 'ttl', 'age', 'claim_count', + 'claim_id'}, set(message)) self.assertEqual(idx, message['body']) self.controller.bulk_delete(self.queue_name, ids,