From 05701896c56d26e11f58ed40a71732261ea43857 Mon Sep 17 00:00:00 2001 From: Malini Kamalambal Date: Mon, 29 Jul 2013 20:18:55 -0400 Subject: [PATCH] Adds test for include_claimed flag This patch set adds test to verify that claimed messages are returned or not, depending on the include_claimed flag. Change-Id: I06f85b7bf78db241cbf0a2d85beac3972f64c9d0 Tests: bug #1202430 --- .../tests/system/messages/test_messages.py | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/marconi/tests/system/messages/test_messages.py b/marconi/tests/system/messages/test_messages.py index 8bc30877a..1736c9ad8 100644 --- a/marconi/tests/system/messages/test_messages.py +++ b/marconi/tests/system/messages/test_messages.py @@ -39,7 +39,11 @@ class TestMessages(testtools.TestCase): test_000_message_setup.tags = ['smoke', 'positive'] def test_001_message_single_insert(self): - """Insert Single Message into the Queue.""" + """Insert Single Message into the Queue. + + This test also verifies that claimed messages are + retuned (or not) depending on the include_claimed flag. + """ doc = msgfnlib.get_message_body(messagecount=1) url = self.cfg.base_url + '/queues/messagetestqueue/messages' @@ -58,6 +62,25 @@ class TestMessages(testtools.TestCase): posted_metadata = doc[0]['body'] self.assertEqual(result_body, posted_metadata) + #Post a claim & verify the include_claimed flag. + url = self.cfg.base_url + '/queues/messagetestqueue/claims' + doc = '{"ttl": 300, "grace": 100}' + result = http.post(url, self.header, doc) + self.assertEqual(result.status_code, 200) + + url = self.cfg.base_url + '/queues/messagetestqueue/messages' \ + '?include_claimed=true' + result = http.get(url, self.header) + self.assertEqual(result.status_code, 200) + + response_message_body = result.json()["messages"][0]["body"] + self.assertEqual(response_message_body, posted_metadata) + + #By default, include_claimed = false + url = self.cfg.base_url + '/queues/messagetestqueue/messages' + result = http.get(url, self.header) + self.assertEqual(result.status_code, 204) + test_001_message_single_insert.tags = ['smoke', 'positive'] def test_002_message_bulk_insert(self):