Fix order of arguments in assertEqual
Some tests used incorrect order assertEqual(observed, expected). The correct order expected by testtools is assertEqual(expected, observed). This patch fix the issue in the module zaqar/tests/functional/wsgi/v1 and base.py file. Partial-Bug: #1259292 Change-Id: Ic0c1d46869d34e4eb4604e5ce6a62edd9b2a4824
This commit is contained in:
parent
dc11333b56
commit
f6f40621e9
@ -137,11 +137,9 @@ class FunctionalTestBase(testing.TestBase):
|
||||
total = self.limits.max_messages_per_claim_or_pop
|
||||
free = total - claimed
|
||||
|
||||
self.assertEqual(result_json['messages']['claimed'], claimed)
|
||||
self.assertEqual(result_json['messages']['free'],
|
||||
free)
|
||||
self.assertEqual(result_json['messages']['total'],
|
||||
total)
|
||||
self.assertEqual(claimed, result_json['messages']['claimed'])
|
||||
self.assertEqual(free, result_json['messages']['free'])
|
||||
self.assertEqual(total, result_json['messages']['total'])
|
||||
|
||||
if 'oldest' in result_json['messages']:
|
||||
oldest_message = result_json['messages']['oldest']
|
||||
@ -174,7 +172,7 @@ class FunctionalTestBase(testing.TestBase):
|
||||
|
||||
response_keys = message.keys()
|
||||
response_keys = sorted(response_keys)
|
||||
self.assertEqual(response_keys, expected_keys)
|
||||
self.assertEqual(expected_keys, response_keys)
|
||||
|
||||
# Verify that age has valid values
|
||||
age = message['age']
|
||||
@ -184,7 +182,7 @@ class FunctionalTestBase(testing.TestBase):
|
||||
# Verify that GET on href returns 200
|
||||
path = message['href']
|
||||
result = self.client.get(path)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
# Verify that created time falls within the last 10 minutes
|
||||
# NOTE(malini): The messages are created during the test.
|
||||
|
@ -49,7 +49,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
|
||||
for i in range(10):
|
||||
result = self.client.post(url, data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
@ddt.data({}, dict(limit=2))
|
||||
def test_claim_messages(self, params):
|
||||
@ -60,7 +60,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 300, "grace": 100}
|
||||
|
||||
result = self.client.post(params=params, data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
actual_message_count = len(result.json())
|
||||
self.assertMessageCount(actual_message_count, message_count)
|
||||
@ -77,14 +77,14 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 300, "grace": 100}
|
||||
|
||||
result = self.client.post(params=params, data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
location = result.headers['Location']
|
||||
|
||||
url = self.cfg.zaqar.url + location
|
||||
|
||||
result = self.client.get(url)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
self.assertSchema(result.json(), 'claim_get')
|
||||
|
||||
@ -99,7 +99,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 300, "grace": 100}
|
||||
|
||||
result = self.client.post(params=params, data=doc)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_claim_more_than_allowed.tags = ['negative']
|
||||
|
||||
@ -109,7 +109,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 300, "grace": 400}
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Patch Claim
|
||||
claim_location = result.headers['Location']
|
||||
@ -117,12 +117,12 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc_updated = {"ttl": 300}
|
||||
|
||||
result = self.client.patch(url, data=doc_updated)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
# verify that the claim TTL is updated
|
||||
result = self.client.get(url)
|
||||
new_ttl = result.json()['ttl']
|
||||
self.assertEqual(new_ttl, 300)
|
||||
self.assertEqual(300, new_ttl)
|
||||
|
||||
test_claim_patch.tags = ['smoke', 'positive']
|
||||
|
||||
@ -132,14 +132,14 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 60, "grace": 60}
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Delete Claimed Messages
|
||||
for rst in result.json():
|
||||
href = rst['href']
|
||||
url = self.cfg.zaqar.url + href
|
||||
result = self.client.delete(url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_delete_claimed_message.tags = ['smoke', 'positive']
|
||||
|
||||
@ -148,7 +148,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 300, "grace": 100}
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Extract claim location and construct the claim URL.
|
||||
location = result.headers['Location']
|
||||
@ -156,7 +156,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
|
||||
# Release Claim.
|
||||
result = self.client.delete(url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_claim_release.tags = ['smoke', 'positive']
|
||||
|
||||
@ -171,7 +171,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": ttl, "grace": 100}
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_claim_invalid_ttl.tags = ['negative']
|
||||
|
||||
@ -186,7 +186,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 100, "grace": grace}
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_claim_invalid_grace.tags = ['negative']
|
||||
|
||||
@ -200,7 +200,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 100, "grace": grace}
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_claim_invalid_limit.tags = ['negative']
|
||||
|
||||
@ -215,7 +215,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
doc = {"ttl": 100, "grace": 100}
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Extract claim location and construct the claim URL.
|
||||
location = result.headers['Location']
|
||||
@ -224,7 +224,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
# Patch Claim.
|
||||
doc = {"ttl": ttl}
|
||||
result = self.client.patch(url, data=doc)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_patch_claim_invalid_ttl.tags = ['negative']
|
||||
|
||||
@ -232,7 +232,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
"""Query Non Existing Claim."""
|
||||
path = '/non-existing-claim'
|
||||
result = self.client.get(path)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
test_query_non_existing_claim.tags = ['negative']
|
||||
|
||||
@ -241,7 +241,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
path = '/non-existing-claim'
|
||||
doc = {"ttl": 400}
|
||||
result = self.client.patch(path, data=doc)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
test_patch_non_existing_claim.tags = ['negative']
|
||||
|
||||
@ -249,7 +249,7 @@ class TestClaims(base.V1FunctionalTestBase):
|
||||
"""Patch Non Existing Claim."""
|
||||
path = '/non-existing-claim'
|
||||
result = self.client.delete(path)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_delete_non_existing_claim.tags = ['negative']
|
||||
|
||||
|
@ -73,7 +73,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
doc = helpers.create_message_body(messagecount=1)
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
response_headers = set(result.headers.keys())
|
||||
self.assertIsSubset(self.headers_response_with_body, response_headers)
|
||||
@ -83,30 +83,30 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
url = self.cfg.zaqar.url + href
|
||||
|
||||
result = self.client.get(url)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
# Compare message metadata
|
||||
result_body = result.json()['body']
|
||||
posted_metadata = doc[0]['body']
|
||||
self.assertEqual(result_body, posted_metadata)
|
||||
self.assertEqual(posted_metadata, result_body)
|
||||
|
||||
# Post a claim & verify the include_claimed flag.
|
||||
url = self.queue_url + '/claims'
|
||||
doc = {"ttl": 300, "grace": 100}
|
||||
result = self.client.post(url, data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
params = {'include_claimed': True,
|
||||
'echo': True}
|
||||
result = self.client.get(params=params)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
response_message_body = result.json()["messages"][0]["body"]
|
||||
self.assertEqual(response_message_body, posted_metadata)
|
||||
self.assertEqual(posted_metadata, response_message_body)
|
||||
|
||||
# By default, include_claimed = false
|
||||
result = self.client.get(self.message_url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_message_single_insert.tags = ['smoke', 'positive']
|
||||
|
||||
@ -116,13 +116,13 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
doc = helpers.create_message_body(messagecount=message_count)
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# GET on posted messages
|
||||
location = result.headers['location']
|
||||
url = self.cfg.zaqar.url + location
|
||||
result = self.client.get(url)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
self.skipTest('Bug #1273335 - Get set of messages returns wrong hrefs '
|
||||
'(happens randomly)')
|
||||
@ -139,7 +139,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
for i in range(message_count)]
|
||||
posted_metadata.sort()
|
||||
|
||||
self.assertEqual(result_body, posted_metadata)
|
||||
self.assertEqual(posted_metadata, result_body)
|
||||
|
||||
test_message_bulk_insert.tags = ['smoke', 'positive']
|
||||
|
||||
@ -154,7 +154,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
messagecount=self.limits.max_messages_per_page)
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
url = ''
|
||||
params['echo'] = True
|
||||
@ -174,7 +174,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
href = result.json()['links'][0]['href']
|
||||
url = self.cfg.zaqar.url + href
|
||||
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_get_message.tags = ['smoke', 'positive']
|
||||
|
||||
@ -183,17 +183,17 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
# Test Setup
|
||||
doc = helpers.create_message_body(messagecount=1)
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Delete posted message
|
||||
href = result.json()['resources'][0]
|
||||
url = self.cfg.zaqar.url + href
|
||||
|
||||
result = self.client.delete(url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
result = self.client.get(url)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
test_message_delete.tags = ['smoke', 'positive']
|
||||
|
||||
@ -202,17 +202,17 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
doc = helpers.create_message_body(messagecount=10)
|
||||
result = self.client.post(data=doc)
|
||||
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Delete posted messages
|
||||
location = result.headers['Location']
|
||||
url = self.cfg.zaqar.url + location
|
||||
|
||||
result = self.client.delete(url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
result = self.client.get(url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_message_bulk_delete.tags = ['smoke', 'positive']
|
||||
|
||||
@ -220,7 +220,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
"""Delete non-existing Messages."""
|
||||
result = self.client.delete('/non-existing')
|
||||
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_message_delete_nonexisting.tags = ['negative']
|
||||
|
||||
@ -229,14 +229,14 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
doc = helpers.create_message_body(messagecount=3)
|
||||
result = self.client.post(data=doc)
|
||||
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Delete posted message
|
||||
location = result.headers['Location']
|
||||
url = self.cfg.zaqar.url + location
|
||||
url += ',nonexisting'
|
||||
result = self.client.delete(url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_message_partial_delete.tags = ['negative']
|
||||
|
||||
@ -245,14 +245,14 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
doc = helpers.create_message_body(messagecount=3)
|
||||
result = self.client.post(data=doc)
|
||||
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Get posted message and a nonexisting message
|
||||
location = result.headers['Location']
|
||||
url = self.cfg.zaqar.url + location
|
||||
url += ',nonexisting'
|
||||
result = self.client.get(url)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
self.assertSchema(result.json(), "message_get_many")
|
||||
|
||||
@ -262,7 +262,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
def test_message_bulk_insert_large_bodies(self, offset):
|
||||
"""Insert just under than max allowed messages."""
|
||||
result = self._post_large_bulk_insert(offset)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
test_message_bulk_insert_large_bodies.tags = ['positive']
|
||||
|
||||
@ -270,7 +270,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
def test_message_bulk_insert_large_bodies_(self, offset):
|
||||
"""Insert just under than max allowed messages."""
|
||||
result = self._post_large_bulk_insert(offset)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_message_bulk_insert_large_bodies_.tags = ['negative']
|
||||
|
||||
@ -285,7 +285,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
helpers.generate_random_string(half_size + 1))
|
||||
|
||||
result = self.client.post(data=doc)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_message_bulk_insert_oversized.tags = ['negative']
|
||||
|
||||
@ -297,7 +297,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
"""
|
||||
params = {'limit': limit}
|
||||
result = self.client.get(params=params)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_message_get_invalid_limit.tags = ['negative']
|
||||
|
||||
@ -312,7 +312,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
range(self.limits.max_messages_per_page + 1)))
|
||||
result = self.client.delete(url)
|
||||
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_message_bulk_delete_negative.tags = ['negative']
|
||||
|
||||
@ -327,7 +327,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
range(self.limits.max_messages_per_page + 1)))
|
||||
result = self.client.get(url)
|
||||
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_message_bulk_get_negative.tags = ['negative']
|
||||
|
||||
@ -336,7 +336,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
url = self.message_url + '?marker=invalid'
|
||||
|
||||
result = self.client.get(url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_get_messages_malformed_marker.tags = ['negative']
|
||||
|
||||
@ -351,7 +351,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
header['Client-ID'] = client_id
|
||||
|
||||
result = self.client.get(url, headers=header)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_get_messages_invalid_client_id.tags = ['negative']
|
||||
|
||||
@ -359,7 +359,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
"""Get Non Existing Message."""
|
||||
path = '/non-existing-message'
|
||||
result = self.client.get(path)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
test_query_non_existing_message.tags = ['negative']
|
||||
|
||||
@ -367,7 +367,7 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
"""Get Set of Non Existing Messages."""
|
||||
path = '?ids=not_there1,not_there2'
|
||||
result = self.client.get(path)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_query_non_existing_message_set.tags = ['negative']
|
||||
|
||||
@ -375,6 +375,6 @@ class TestMessages(base.V1FunctionalTestBase):
|
||||
"""Delete Non Existing Message."""
|
||||
path = '/non-existing-message'
|
||||
result = self.client.delete(path)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_delete_non_existing_message.tags = ['negative']
|
||||
|
@ -92,15 +92,15 @@ class TestInsertQueue(base.V1FunctionalTestBase):
|
||||
self.addCleanup(self.client.delete, self.url)
|
||||
|
||||
result = self.client.put(self.url)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
response_headers = set(result.headers.keys())
|
||||
self.assertIsSubset(self.headers_response_empty, response_headers)
|
||||
|
||||
self.url = self.url + '/metadata'
|
||||
result = self.client.get(self.url)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(result.json(), {})
|
||||
self.assertEqual(200, result.status_code)
|
||||
self.assertEqual({}, result.json())
|
||||
|
||||
test_insert_queue.tags = ['positive', 'smoke']
|
||||
|
||||
@ -117,11 +117,11 @@ class TestInsertQueue(base.V1FunctionalTestBase):
|
||||
self.addCleanup(self.client.delete, self.url)
|
||||
|
||||
result = self.client.put(self.url)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
self.url = self.url + '/metadata'
|
||||
result = self.client.get(self.url)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_insert_queue_invalid_name.tags = ['negative']
|
||||
|
||||
@ -141,7 +141,7 @@ class TestInsertQueue(base.V1FunctionalTestBase):
|
||||
header['X-Auth-Token'] = 'invalid'
|
||||
|
||||
result = self.client.put(self.url, headers=header)
|
||||
self.assertEqual(result.status_code, 401)
|
||||
self.assertEqual(401, result.status_code)
|
||||
|
||||
test_insert_queue_invalid_authtoken.tags = ['negative']
|
||||
|
||||
@ -152,7 +152,7 @@ class TestInsertQueue(base.V1FunctionalTestBase):
|
||||
|
||||
header = {"Accept": 'plain/text'}
|
||||
result = self.client.put(path, headers=header)
|
||||
self.assertEqual(result.status_code, 406)
|
||||
self.assertEqual(406, result.status_code)
|
||||
|
||||
test_insert_queue_header_plaintext.tags = ['negative']
|
||||
|
||||
@ -163,7 +163,7 @@ class TestInsertQueue(base.V1FunctionalTestBase):
|
||||
self.addCleanup(self.client.delete, url=path, headers=headers)
|
||||
|
||||
result = self.client.put(path, headers=headers)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
test_insert_queue_header_asterisk.tags = ['positive']
|
||||
|
||||
@ -174,13 +174,13 @@ class TestInsertQueue(base.V1FunctionalTestBase):
|
||||
self.addCleanup(self.client.delete, self.url)
|
||||
result = self.client.put(self.url, data=doc)
|
||||
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
self.url = self.base_url + '/queues/hasmetadata/metadata'
|
||||
result = self.client.get(self.url)
|
||||
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(result.json(), {})
|
||||
self.assertEqual(200, result.status_code)
|
||||
self.assertEqual({}, result.json())
|
||||
|
||||
test_insert_queue_with_metadata.tags = ['negative']
|
||||
|
||||
@ -218,10 +218,10 @@ class TestQueueMetaData(base.V1FunctionalTestBase):
|
||||
def test_insert_queue_metadata(self, doc):
|
||||
"""Insert Queue with empty json."""
|
||||
result = self.client.put(data=doc)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
result = self.client.get()
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
doc_decoded = {}
|
||||
for k, v in doc.items():
|
||||
@ -244,7 +244,7 @@ class TestQueueMetaData(base.V1FunctionalTestBase):
|
||||
"""Insert invalid metadata."""
|
||||
|
||||
result = self.client.put(data=doc)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_insert_queue_invalid_metadata.tags = ['negative']
|
||||
|
||||
@ -275,7 +275,7 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
result = self.client.get('/{0}/queues'
|
||||
.format('v1'))
|
||||
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
self.assertSchema(result.json(), 'queue_list')
|
||||
|
||||
test_list_queues.tags = ['smoke', 'positive']
|
||||
@ -290,7 +290,7 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
result = self.client.get('/{0}/queues'
|
||||
.format("v1"),
|
||||
params=params)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
self.assertSchema(result.json(), 'queue_list')
|
||||
|
||||
response_keys = result.json()['queues'][0].keys()
|
||||
@ -306,7 +306,7 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
result = self.client.get('/{0}/queues'
|
||||
.format("v1"),
|
||||
params=params)
|
||||
self.assertEqual(result.status_code, 400)
|
||||
self.assertEqual(400, result.status_code)
|
||||
|
||||
test_list_queue_invalid_limit.tags = ['negative']
|
||||
|
||||
@ -315,7 +315,7 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
|
||||
result = self.client.get('/{0}/health'
|
||||
.format("v1"))
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_check_health.tags = ['positive']
|
||||
|
||||
@ -325,10 +325,10 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
self.client.put(self.queue_url)
|
||||
self.addCleanup(self.client.delete, self.queue_url)
|
||||
result = self.client.get(self.queue_url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
result = self.client.head(self.queue_url)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_check_queue_exists.tags = ['positive']
|
||||
|
||||
@ -336,10 +336,10 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
"""Checks non-existing queue."""
|
||||
path = '/{0}/queues/nonexistingqueue'.format("v1")
|
||||
result = self.client.get(path)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
result = self.client.head(path)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
test_check_queue_exists_negative.tags = ['negative']
|
||||
|
||||
@ -348,7 +348,7 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
|
||||
path = '/{0}/queues?marker=zzz'.format("v1")
|
||||
result = self.client.get(path)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
test_get_queue_malformed_marker.tags = ['negative']
|
||||
|
||||
@ -357,17 +357,17 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
|
||||
result = self.client.put(self.queue_url)
|
||||
self.addCleanup(self.client.delete, self.queue_url)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
stats_url = self.queue_url + '/stats'
|
||||
|
||||
# Get stats on an empty queue
|
||||
result = self.client.get(stats_url)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
expected_response = {'messages':
|
||||
{'claimed': 0, 'total': 0, 'free': 0}}
|
||||
self.assertEqual(result.json(), expected_response)
|
||||
self.assertEqual(expected_response, result.json())
|
||||
|
||||
test_get_stats_empty_queue.tags = ['positive']
|
||||
|
||||
@ -376,7 +376,7 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
"""Get stats on a queue."""
|
||||
result = self.client.put(self.queue_url)
|
||||
self.addCleanup(self.client.delete, self.queue_url)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Post Messages to the test queue
|
||||
doc = helpers.create_message_body(
|
||||
@ -384,18 +384,18 @@ class TestQueueMisc(base.V1FunctionalTestBase):
|
||||
|
||||
message_url = self.queue_url + '/messages'
|
||||
result = self.client.post(message_url, data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
if claimed > 0:
|
||||
claim_url = self.queue_url + '/claims?limit=' + str(claimed)
|
||||
doc = {'ttl': 300, 'grace': 300}
|
||||
result = self.client.post(claim_url, data=doc)
|
||||
self.assertEqual(result.status_code, 201)
|
||||
self.assertEqual(201, result.status_code)
|
||||
|
||||
# Get stats on the queue.
|
||||
stats_url = self.queue_url + '/stats'
|
||||
result = self.client.get(stats_url)
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assertEqual(200, result.status_code)
|
||||
|
||||
self.assertQueueStats(result.json(), claimed)
|
||||
|
||||
@ -426,36 +426,36 @@ class TestQueueNonExisting(base.V1FunctionalTestBase):
|
||||
def test_get_queue(self):
|
||||
"""Get non existing Queue."""
|
||||
result = self.client.get()
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
def test_get_stats(self):
|
||||
"""Get stats on non existing Queue."""
|
||||
result = self.client.get('/stats')
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
def test_get_metadata(self):
|
||||
"""Get metadata on non existing Queue."""
|
||||
result = self.client.get('/metadata')
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
def test_get_messages(self):
|
||||
"""Get messages on non existing Queue."""
|
||||
result = self.client.get('/messages')
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
def test_post_messages(self):
|
||||
"""Post messages to a non existing Queue."""
|
||||
doc = [{"ttl": 200, "body": {"Home": ""}}]
|
||||
result = self.client.post('/messages', data=doc)
|
||||
self.assertEqual(result.status_code, 404)
|
||||
self.assertEqual(404, result.status_code)
|
||||
|
||||
def test_claim_messages(self):
|
||||
"""Claim messages from a non existing Queue."""
|
||||
doc = {"ttl": 200, "grace": 300}
|
||||
result = self.client.post('/claims', data=doc)
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
||||
def test_delete_queue(self):
|
||||
"""Delete non existing Queue."""
|
||||
result = self.client.delete()
|
||||
self.assertEqual(result.status_code, 204)
|
||||
self.assertEqual(204, result.status_code)
|
||||
|
Loading…
x
Reference in New Issue
Block a user