def test_002_message_bulk_insert(self): """Bulk Insert Messages into the Queue.""" message_count = 30 doc = msgfnlib.get_message_body(messagecount=message_count) url = self.cfg.base_url + '/queues/messagetestqueue/messages' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201) #GET on posted messages location = result.headers['location'] url = self.cfg.base_server + location result = http.get(url, self.header) self.assertEqual(result.status_code, 200) #Compare message metadata result_body = [result.json()['messages'][i]['body'] for i in range(len(result.json()['messages']))] result_body.sort() posted_metadata = [doc[i]['body'] for i in range(message_count)] posted_metadata.sort() self.assertEqual(result_body, posted_metadata)
def test_007_message_bulk_insert_60(self): """Insert more than max allowed messages. Marconi allows a maximum of 50 message per POST. """ doc = msgfnlib.get_message_body(messagecount=60) url = self.cfg.base_url + '/queues/messagetestqueue/messages' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 400)
def test_000_claim_setup(self): """Create Queue, Post Messages for Claim Tests.""" url = self.cfg.base_url + '/queues/claimtestqueue' result = http.put(url, self.header) self.assertEqual(result.status_code, 201) #Post Messages url = self.cfg.base_url + '/queues/claimtestqueue/messages' doc = msgfnlib.get_message_body(messagecount=50) for i in range(5): result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201)
def test_009_message_partial_delete(self): """Delete Messages will be partially successful.""" doc = msgfnlib.get_message_body(messagecount=3) url = self.cfg.base_url + '/queues/messagetestqueue/messages' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201) #Delete posted message location = result.headers['Location'] url = self.cfg.base_server + location url += ',nonexisting' result = http.delete(url, self.header) self.assertEqual(result.status_code, 204)
def test_006_message_delete(self): """Delete Message.""" doc = msgfnlib.get_message_body(messagecount=1) url = self.cfg.base_url + '/queues/messagetestqueue/messages' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201) #Delete posted message location = result.headers['location'] url = self.cfg.base_server + location result = http.delete(url, self.header) self.assertEqual(result.status_code, 204) result = http.get(url, self.header) self.assertEqual(result.status_code, 404)
def test_006_message_delete(self): """Delete Message.""" doc = msgfnlib.get_message_body(messagecount=1) url = self.cfg.base_url + '/queues/messagetestqueue/messages' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201) #Delete posted message href = result.json()['resources'][0] url = self.cfg.base_server + href result = http.delete(url, self.header) self.assertEqual(result.status_code, 204) result = http.get(url, self.header) self.assertEqual(result.status_code, 404)
def test_001_message_single_insert(self): """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' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201) response_headers = set(result.headers.keys()) self.assertIsSubset(self.headers_response_with_body, response_headers) #GET on posted message href = result.json()['resources'][0] url = self.cfg.base_server + href result = http.get(url, self.header) self.assertEqual(result.status_code, 200) #Compare message metadata result_body = result.json()['body'] 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)
def test_001_message_single_insert(self): """Insert Single Message into the Queue.""" doc = msgfnlib.get_message_body(messagecount=1) url = self.cfg.base_url + '/queues/messagetestqueue/messages' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201) #GET on posted message location = result.headers['location'] url = self.cfg.base_server + location result = http.get(url, self.header) self.assertEqual(result.status_code, 200) #Compare message metadata result_body = result.json()[0]['body'] posted_metadata = doc[0]['body'] self.assertEqual(result_body, posted_metadata)