def test_007_claim_expired(self): """Update, Get and Release Expired Claim.""" #Test Setup - Post Claim. url = self.cfg.base_url + '/queues/claimtestqueue/claims' doc = '{"ttl": 1, "grace": 0}' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201) time.sleep(2) #Extract claim location and construct the claim URL. location = result.headers['Location'] url = self.cfg.base_server + location #Update Expired Claim. doc = '{"ttl": 300}' result = http.patch(url, self.header, doc) self.assertEqual(result.status_code, 404) #Get Expired Claim. result = http.get(url, self.header) self.assertEqual(result.status_code, 404) #Release Expired Claim. result = http.delete(url, self.header) self.assertEqual(result.status_code, 204)
def patch_claim(*claim_response): """Patches a claim & verifies the results. Extracts claim id from the POST response input & updates the claim. If PATCH claim succeeds, verifies that the claim TTL is extended. :param *claim_response: [headers, body] returned for the original claim """ test_result_flag = False headers = claim_response[0] location = headers['Location'] url = functionlib.create_url_from_appender(location) header = functionlib.create_marconi_headers() ttl_value = 300 payload = '{"ttl": ttlvalue }' payload = payload.replace('ttlvalue', str(ttl_value)) patch_response = http.patch(url, header, body=payload) if patch_response.status_code == 204: test_result_flag = verify_patch_claim(url, header, ttl_value) else: print 'Patch HTTP Response code: {}'.format(patch_response.status_code) print patch_response.headers print patch_response.text return test_result_flag
def test_005_claim_patch(self): """Update Claim.""" #Test Setup - Post Claim url = self.cfg.base_url + '/queues/claimtestqueue/claims' doc = '{"ttl": 300, "grace": 400}' result = http.post(url, self.header, doc) self.assertEqual(result.status_code, 201) #Patch Claim claim_location = result.headers['Location'] url = self.cfg.base_server + claim_location doc_updated = '{"ttl": 300}' result = http.patch(url, self.header, doc_updated) self.assertEqual(result.status_code, 204) test_result_flag = claimfnlib.verify_patch_claim(url, self.header, 300) self.assertEqual(test_result_flag, True)