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/unit/transport/wsgi/v1/ . Partial-Bug: #1259292 Change-Id: I4e2252efd810ab658c1d3ad03081c3807daebfcb
This commit is contained in:
parent
db445425d0
commit
6f4c8beacc
@ -40,4 +40,4 @@ class TestAuth(base.V1Base):
|
||||
headers=self.headers)
|
||||
|
||||
self.app(env, self.srmock)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_401)
|
||||
self.assertEqual(falcon.HTTP_401, self.srmock.status)
|
||||
|
@ -44,12 +44,12 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
doc = '{"_ttl": 60}'
|
||||
|
||||
self.simulate_put(self.queue_path, self.project_id, body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
doc = jsonutils.dumps([{'body': 239, 'ttl': 300}] * 10)
|
||||
self.simulate_post(self.queue_path + '/messages', self.project_id,
|
||||
body=doc, headers={'Client-ID': str(uuid.uuid4())})
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def tearDown(self):
|
||||
storage = self.boot.storage._storage
|
||||
@ -67,19 +67,19 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
@ddt.data(None, '[', '[]', '{}', '.', '"fail"')
|
||||
def test_bad_claim(self, doc):
|
||||
self.simulate_post(self.claims_path, self.project_id, body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
href = self._get_a_claim()
|
||||
|
||||
self.simulate_patch(href, self.project_id, body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_exceeded_claim(self):
|
||||
self.simulate_post(self.claims_path, self.project_id,
|
||||
body='{"ttl": 100, "grace": 60}',
|
||||
query_string='limit=21')
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data((-1, -1), (59, 60), (60, 59), (60, 43201), (43201, 60))
|
||||
def test_unacceptable_ttl_or_grace(self, ttl_grace):
|
||||
@ -87,7 +87,7 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
self.simulate_post(self.claims_path, self.project_id,
|
||||
body=jsonutils.dumps({'ttl': ttl, 'grace': grace}))
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 59, 43201)
|
||||
def test_unacceptable_new_ttl(self, ttl):
|
||||
@ -96,7 +96,7 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
self.simulate_patch(href, self.project_id,
|
||||
body=jsonutils.dumps({'ttl': ttl}))
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def _get_a_claim(self):
|
||||
doc = '{"ttl": 100, "grace": 60}'
|
||||
@ -108,7 +108,7 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
|
||||
# First, claim some messages
|
||||
body = self.simulate_post(self.claims_path, self.project_id, body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
claimed = jsonutils.loads(body[0])
|
||||
claim_href = self.srmock.headers_dict['Location']
|
||||
@ -117,7 +117,7 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
# No more messages to claim
|
||||
self.simulate_post(self.claims_path, self.project_id, body=doc,
|
||||
query_string='limit=3')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
@ -126,15 +126,15 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
# Listing messages, by default, won't include claimed
|
||||
body = self.simulate_get(self.messages_path, self.project_id,
|
||||
headers=headers)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Include claimed messages this time
|
||||
body = self.simulate_get(self.messages_path, self.project_id,
|
||||
query_string='include_claimed=true',
|
||||
headers=headers)
|
||||
listed = jsonutils.loads(body[0])
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(len(listed['messages']), len(claimed))
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
self.assertEqual(len(claimed), len(listed['messages']))
|
||||
|
||||
now = timeutils.utcnow() + datetime.timedelta(seconds=10)
|
||||
timeutils_utcnow = 'oslo_utils.timeutils.utcnow'
|
||||
@ -144,35 +144,35 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
|
||||
claim = jsonutils.loads(body[0])
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(self.srmock.headers_dict['Content-Location'],
|
||||
claim_href)
|
||||
self.assertEqual(claim['ttl'], 100)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
self.assertEqual(claim_href,
|
||||
self.srmock.headers_dict['Content-Location'])
|
||||
self.assertEqual(100, claim['ttl'])
|
||||
# NOTE(cpp-cabrera): verify that claim age is non-negative
|
||||
self.assertThat(claim['age'], matchers.GreaterThan(-1))
|
||||
|
||||
# Try to delete the message without submitting a claim_id
|
||||
self.simulate_delete(message_href, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_403)
|
||||
self.assertEqual(falcon.HTTP_403, self.srmock.status)
|
||||
|
||||
# Delete the message and its associated claim
|
||||
self.simulate_delete(message_href, self.project_id,
|
||||
query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Try to get it from the wrong project
|
||||
self.simulate_get(message_href, 'bogus_project', query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Get the message
|
||||
self.simulate_get(message_href, self.project_id, query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Update the claim
|
||||
new_claim_ttl = '{"ttl": 60}'
|
||||
creation = timeutils.utcnow()
|
||||
self.simulate_patch(claim_href, self.project_id, body=new_claim_ttl)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Get the claimed messages (again)
|
||||
body = self.simulate_get(claim_href, self.project_id)
|
||||
@ -180,58 +180,58 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
claim = jsonutils.loads(body[0])
|
||||
message_href, params = claim['messages'][0]['href'].split('?')
|
||||
|
||||
self.assertEqual(claim['ttl'], 60)
|
||||
self.assertEqual(60, claim['ttl'])
|
||||
estimated_age = timeutils.delta_seconds(creation, query)
|
||||
self.assertTrue(estimated_age > claim['age'])
|
||||
|
||||
# Delete the claim
|
||||
self.simulate_delete(claim['href'], 'bad_id')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
self.simulate_delete(claim['href'], self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Try to delete a message with an invalid claim ID
|
||||
self.simulate_delete(message_href, self.project_id,
|
||||
query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
# Make sure it wasn't deleted!
|
||||
self.simulate_get(message_href, self.project_id, query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
# Try to get a claim that doesn't exist
|
||||
self.simulate_get(claim['href'])
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Try to update a claim that doesn't exist
|
||||
self.simulate_patch(claim['href'], body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
def test_post_claim_nonexistent_queue(self):
|
||||
path = self.url_prefix + '/queues/nonexistent/claims'
|
||||
self.simulate_post(path, self.project_id,
|
||||
body='{"ttl": 100, "grace": 60}')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_get_claim_nonexistent_queue(self):
|
||||
path = self.url_prefix + '/queues/nonexistent/claims/aaabbbba'
|
||||
self.simulate_get(path)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# NOTE(cpp-cabrera): regression test against bug #1203842
|
||||
def test_get_nonexistent_claim_404s(self):
|
||||
self.simulate_get(self.claims_path + '/a')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
def test_delete_nonexistent_claim_204s(self):
|
||||
self.simulate_delete(self.claims_path + '/a')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_patch_nonexistent_claim_404s(self):
|
||||
patch_data = jsonutils.dumps({'ttl': 100})
|
||||
self.simulate_patch(self.claims_path + '/a', body=patch_data)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
|
||||
class TestClaimsFaultyDriver(base.V1BaseFaulty):
|
||||
@ -244,13 +244,13 @@ class TestClaimsFaultyDriver(base.V1BaseFaulty):
|
||||
doc = '{"ttl": 100, "grace": 60}'
|
||||
|
||||
self.simulate_post(claims_path, project_id, body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
self.simulate_get(claims_path + '/nichts', project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
self.simulate_patch(claims_path + '/nichts', project_id, body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
self.simulate_delete(claims_path + '/foo', project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
@ -45,14 +45,14 @@ class TestDefaultLimits(base.V1Base):
|
||||
# 2 queues to list
|
||||
self.addCleanup(self.simulate_delete, self.queue_path + '/q2')
|
||||
self.simulate_put(self.queue_path + '/q2')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
with self._prepare_queues(storage.DEFAULT_QUEUES_PER_PAGE + 1):
|
||||
result = self.simulate_get(self.queue_path)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
queues = jsonutils.loads(result[0])['queues']
|
||||
self.assertEqual(len(queues), storage.DEFAULT_QUEUES_PER_PAGE)
|
||||
self.assertEqual(storage.DEFAULT_QUEUES_PER_PAGE, len(queues))
|
||||
|
||||
def test_message_listing(self):
|
||||
self._prepare_messages(storage.DEFAULT_MESSAGES_PER_PAGE + 1)
|
||||
@ -60,10 +60,10 @@ class TestDefaultLimits(base.V1Base):
|
||||
result = self.simulate_get(self.messages_path,
|
||||
headers={'Client-ID': str(uuid.uuid4())})
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
messages = jsonutils.loads(result[0])['messages']
|
||||
self.assertEqual(len(messages), storage.DEFAULT_MESSAGES_PER_PAGE)
|
||||
self.assertEqual(storage.DEFAULT_MESSAGES_PER_PAGE, len(messages))
|
||||
|
||||
def test_claim_creation(self):
|
||||
self._prepare_messages(storage.DEFAULT_MESSAGES_PER_CLAIM + 1)
|
||||
@ -71,10 +71,10 @@ class TestDefaultLimits(base.V1Base):
|
||||
result = self.simulate_post(self.claims_path,
|
||||
body='{"ttl": 60, "grace": 60}')
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
messages = jsonutils.loads(result[0])
|
||||
self.assertEqual(len(messages), storage.DEFAULT_MESSAGES_PER_CLAIM)
|
||||
self.assertEqual(storage.DEFAULT_MESSAGES_PER_CLAIM, len(messages))
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _prepare_queues(self, count):
|
||||
@ -83,7 +83,7 @@ class TestDefaultLimits(base.V1Base):
|
||||
|
||||
for path in queue_paths:
|
||||
self.simulate_put(path)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
yield
|
||||
|
||||
@ -95,4 +95,4 @@ class TestDefaultLimits(base.V1Base):
|
||||
self.simulate_post(self.messages_path, body=doc,
|
||||
headers={'Client-ID': str(uuid.uuid4())})
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
@ -24,10 +24,10 @@ class TestHealth(base.V1Base):
|
||||
|
||||
def test_get(self):
|
||||
response = self.simulate_get('/v1/health')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(response, [])
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
self.assertEqual([], response)
|
||||
|
||||
def test_head(self):
|
||||
response = self.simulate_head('/v1/health')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(response, [])
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
self.assertEqual([], response)
|
||||
|
@ -25,10 +25,10 @@ class TestHomeDocument(base.V1Base):
|
||||
|
||||
def test_json_response(self):
|
||||
body = self.simulate_get(self.url_prefix)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
content_type = self.srmock.headers_dict['Content-Type']
|
||||
self.assertEqual(content_type, 'application/json-home')
|
||||
self.assertEqual('application/json-home', content_type)
|
||||
|
||||
try:
|
||||
jsonutils.loads(body[0])
|
||||
@ -37,7 +37,7 @@ class TestHomeDocument(base.V1Base):
|
||||
|
||||
def test_href_template(self):
|
||||
body = self.simulate_get(self.url_prefix)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
resp = jsonutils.loads(body[0])
|
||||
queue_href_template = resp['resources']['rel/queue']['href-template']
|
||||
path_1 = 'https://zaqar.example.com' + self.url_prefix
|
||||
@ -51,7 +51,7 @@ class TestHomeDocument(base.V1Base):
|
||||
url = urlparse.urljoin(path_1, queue_href_template)
|
||||
expected = ('https://zaqar.example.com' + self.url_prefix +
|
||||
'/queues/foo')
|
||||
self.assertEqual(url.format(queue_name='foo'), expected)
|
||||
self.assertEqual(expected, url.format(queue_name='foo'))
|
||||
|
||||
url = urlparse.urljoin(path_2, queue_href_template)
|
||||
self.assertEqual(url.format(queue_name='foo'), expected)
|
||||
self.assertEqual(expected, url.format(queue_name='foo'))
|
||||
|
@ -49,4 +49,4 @@ class TestMediaType(base.V1Base):
|
||||
headers=headers)
|
||||
|
||||
self.app(env, self.srmock)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_406)
|
||||
self.assertEqual(falcon.HTTP_406, self.srmock.status)
|
||||
|
@ -43,7 +43,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
doc = {'weight': 100, 'uri': uri}
|
||||
self.simulate_put(self.url_prefix + '/pools/' + str(i),
|
||||
body=jsonutils.dumps(doc))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
self.project_id = '7e55e1a7e'
|
||||
|
||||
@ -80,12 +80,12 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
|
||||
result = self.simulate_post(self.messages_path, self.project_id,
|
||||
body=sample_doc, headers=self.headers)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
|
||||
msg_ids = self._get_msg_ids(self.srmock.headers_dict)
|
||||
self.assertEqual(len(msg_ids), len(sample_messages))
|
||||
self.assertEqual(len(sample_messages), len(msg_ids))
|
||||
|
||||
expected_resources = [six.text_type(self.messages_path + '/' + id)
|
||||
for id in msg_ids]
|
||||
@ -96,7 +96,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
# to enqueue the entire batch of messages.
|
||||
self.assertFalse(result_doc['partial'])
|
||||
|
||||
self.assertEqual(len(msg_ids), len(sample_messages))
|
||||
self.assertEqual(len(sample_messages), len(msg_ids))
|
||||
|
||||
lookup = dict([(m['ttl'], m['body']) for m in sample_messages])
|
||||
|
||||
@ -111,18 +111,18 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
|
||||
# Wrong project ID
|
||||
self.simulate_get(message_uri, '777777')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Correct project ID
|
||||
result = self.simulate_get(message_uri, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(self.srmock.headers_dict['Content-Location'],
|
||||
message_uri)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
self.assertEqual(message_uri,
|
||||
self.srmock.headers_dict['Content-Location'])
|
||||
|
||||
# Check message properties
|
||||
message = jsonutils.loads(result[0])
|
||||
self.assertEqual(message['href'], message_uri)
|
||||
self.assertEqual(message['body'], lookup[message['ttl']])
|
||||
self.assertEqual(message_uri, message['href'])
|
||||
self.assertEqual(lookup[message['ttl']], message['body'])
|
||||
|
||||
# no negative age
|
||||
# NOTE(cpp-cabrera): testtools lacks GreaterThanEqual on py26
|
||||
@ -134,7 +134,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
result = self.simulate_get(self.messages_path, self.project_id,
|
||||
query_string=query_string)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
expected_ttls = set(m['ttl'] for m in sample_messages)
|
||||
actual_ttls = set(m['ttl'] for m in result_doc)
|
||||
@ -150,21 +150,21 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
self.simulate_get(self.messages_path, self.project_id,
|
||||
query_string=query_string)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
# Listing restriction
|
||||
self.simulate_get(self.messages_path, self.project_id,
|
||||
query_string='limit=21',
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
# Bulk deletion restriction
|
||||
query_string = 'ids=' + ','.join([msg_id] * 22)
|
||||
self.simulate_delete(self.messages_path, self.project_id,
|
||||
query_string=query_string)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_post_single(self):
|
||||
sample_messages = [
|
||||
@ -193,7 +193,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
path = path.encode('utf-8')
|
||||
|
||||
self._post_messages(path)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_post_with_long_queue_name(self):
|
||||
# NOTE(kgriffs): This test verifies that routes with
|
||||
@ -204,22 +204,22 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
|
||||
game_title = 'v' * validation.QUEUE_NAME_MAX_LEN
|
||||
self._post_messages(queues_path + game_title + '/messages')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
game_title += 'v'
|
||||
self._post_messages(queues_path + game_title + '/messages')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_post_to_missing_queue(self):
|
||||
self._post_messages(self.url_prefix + '/queues/nonexistent/messages')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
def test_get_from_missing_queue(self):
|
||||
self.simulate_get(self.url_prefix + '/queues/nonexistent/messages',
|
||||
self.project_id,
|
||||
headers={'Client-ID':
|
||||
'dfcd3238-425c-11e3-8a80-28cfe91478b9'})
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
@ddt.data('', '0xdeadbeef', '550893e0-2b6e-11e3-835a-5cf9dd72369')
|
||||
def test_bad_client_id(self, text_id):
|
||||
@ -227,13 +227,13 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
body='{"ttl": 60, "body": ""}',
|
||||
headers={'Client-ID': text_id})
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_get(self.queue_path + '/messages',
|
||||
query_string='limit=3&echo=true',
|
||||
headers={'Client-ID': text_id})
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(None, '[', '[]', '{}', '.')
|
||||
def test_post_bad_message(self, document):
|
||||
@ -241,7 +241,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
body=document,
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 59, 1209601)
|
||||
def test_unacceptable_ttl(self, ttl):
|
||||
@ -249,7 +249,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
body=jsonutils.dumps([{'ttl': ttl, 'body': None}]),
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_exceeded_message_posting(self):
|
||||
# Total (raw request) size
|
||||
@ -263,7 +263,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
body=long_doc,
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data('{"overflow": 9223372036854775808}',
|
||||
'{"underflow": -9223372036854775809}')
|
||||
@ -272,7 +272,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
body=document,
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_delete(self):
|
||||
self._post_messages(self.messages_path)
|
||||
@ -280,17 +280,17 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
target = self.messages_path + '/' + msg_id
|
||||
|
||||
self.simulate_get(target, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
self.simulate_delete(target, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
self.simulate_get(target, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Safe to delete non-existing ones
|
||||
self.simulate_delete(target, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_bulk_delete(self):
|
||||
path = self.queue_path + '/messages'
|
||||
@ -299,24 +299,24 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
|
||||
# Deleting the whole collection is denied
|
||||
self.simulate_delete(path, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_delete(target, self.project_id, query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
self.simulate_get(target, self.project_id, query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Safe to delete non-existing ones
|
||||
self.simulate_delete(target, self.project_id, query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Even after the queue is gone
|
||||
self.simulate_delete(self.queue_path, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
self.simulate_delete(target, self.project_id, query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_list(self):
|
||||
path = self.queue_path + '/messages'
|
||||
@ -327,9 +327,9 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
query_string=query_string,
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(self.srmock.headers_dict['Content-Location'],
|
||||
path + '?' + query_string)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
self.assertEqual(path + '?' + query_string,
|
||||
self.srmock.headers_dict['Content-Location'])
|
||||
|
||||
cnt = 0
|
||||
while self.srmock.status == falcon.HTTP_200:
|
||||
@ -338,23 +338,23 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
|
||||
for msg in contents['messages']:
|
||||
self.simulate_get(msg['href'], self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
body = self.simulate_get(target, self.project_id,
|
||||
query_string=params,
|
||||
headers=self.headers)
|
||||
cnt += 1
|
||||
|
||||
self.assertEqual(cnt, 4)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(4, cnt)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Stats
|
||||
body = self.simulate_get(self.queue_path + '/stats', self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
message_stats = jsonutils.loads(body[0])['messages']
|
||||
self.assertEqual(self.srmock.headers_dict['Content-Location'],
|
||||
self.queue_path + '/stats')
|
||||
self.assertEqual(self.queue_path + '/stats',
|
||||
self.srmock.headers_dict['Content-Location'])
|
||||
|
||||
# NOTE(kgriffs): The other parts of the stats are tested
|
||||
# in tests.storage.base and so are not repeated here.
|
||||
@ -367,7 +367,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
self.simulate_get(self.url_prefix + '/queues/nonexistent/messages',
|
||||
self.project_id,
|
||||
headers=self.headers)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_list_with_bad_marker(self):
|
||||
path = self.queue_path + '/messages'
|
||||
@ -378,7 +378,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
query_string=query_string,
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_no_uuid(self):
|
||||
path = self.queue_path + '/messages'
|
||||
@ -387,48 +387,48 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
headers={},
|
||||
body='[{"body": 0, "ttl": 100}]')
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_get(path, '7e7e7e', headers={})
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
# NOTE(cpp-cabrera): regression test against bug #1210633
|
||||
def test_when_claim_deleted_then_messages_unclaimed(self):
|
||||
path = self.queue_path
|
||||
self._post_messages(path + '/messages', repeat=5)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
# post claim
|
||||
self.simulate_post(path + '/claims', self.project_id,
|
||||
body='{"ttl": 100, "grace": 100}')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
location = self.srmock.headers_dict['location']
|
||||
|
||||
# release claim
|
||||
self.simulate_delete(location, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# get unclaimed messages
|
||||
self.simulate_get(path + '/messages', self.project_id,
|
||||
query_string='echo=true',
|
||||
headers=self.headers)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
# NOTE(cpp-cabrera): regression test against bug #1203842
|
||||
def test_get_nonexistent_message_404s(self):
|
||||
path = self.url_prefix + '/queues/notthere/messages/a'
|
||||
self.simulate_get(path)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
def test_get_multiple_invalid_messages_204s(self):
|
||||
path = self.url_prefix + '/queues/notthere/messages'
|
||||
self.simulate_get(path, query_string='ids=a,b,c')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_delete_multiple_invalid_messages_204s(self):
|
||||
path = self.url_prefix + '/queues/notthere/messages'
|
||||
self.simulate_delete(path, query_string='ids=a,b,c')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_delete_message_with_invalid_claim_doesnt_delete_message(self):
|
||||
path = self.queue_path
|
||||
@ -437,10 +437,10 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
|
||||
self.simulate_delete(location, self.project_id,
|
||||
query_string='claim_id=invalid')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_get(location, self.project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
def test_no_duplicated_messages_path_in_href(self):
|
||||
"""Test for bug 1240897."""
|
||||
@ -496,14 +496,14 @@ class TestMessagesFaultyDriver(base.V1BaseFaulty):
|
||||
self.simulate_post(path, project_id,
|
||||
body=doc,
|
||||
headers=headers)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
self.simulate_get(path, project_id,
|
||||
headers=headers)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
self.simulate_get(path + '/nonexistent', project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
self.simulate_delete(path + '/nada', project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
@ -90,28 +90,28 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
self.doc = {'weight': 100, 'uri': self.mongodb_url}
|
||||
self.pool = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
self.simulate_put(self.pool, body=jsonutils.dumps(self.doc))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPoolsMongoDB, self).tearDown()
|
||||
self.simulate_delete(self.pool)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_put_pool_works(self):
|
||||
name = str(uuid.uuid1())
|
||||
weight, uri = self.doc['weight'], self.doc['uri']
|
||||
with pool(self, name, weight, uri):
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def test_put_raises_if_missing_fields(self):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
self.simulate_put(path, body=jsonutils.dumps({'weight': 100}))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps(
|
||||
{'uri': self.mongodb_url}))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 2**32+1, 'big')
|
||||
def test_put_raises_if_invalid_weight(self, weight):
|
||||
@ -119,52 +119,52 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
doc = {'weight': weight, 'uri': 'a'}
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps(doc))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 2**32+1, [], 'localhost:27017')
|
||||
def test_put_raises_if_invalid_uri(self, uri):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps({'weight': 1, 'uri': uri}))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 'wee', [])
|
||||
def test_put_raises_if_invalid_options(self, options):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
doc = {'weight': 1, 'uri': 'a', 'options': options}
|
||||
self.simulate_put(path, body=jsonutils.dumps(doc))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_put_existing_overwrites(self):
|
||||
# NOTE(cabrera): setUp creates default pool
|
||||
expect = self.doc
|
||||
self.simulate_put(self.pool,
|
||||
body=jsonutils.dumps(expect))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
result = self.simulate_get(self.pool)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
doc = jsonutils.loads(result[0])
|
||||
self.assertEqual(doc['weight'], expect['weight'])
|
||||
self.assertEqual(doc['uri'], expect['uri'])
|
||||
self.assertEqual(expect['weight'], doc['weight'])
|
||||
self.assertEqual(expect['uri'], doc['uri'])
|
||||
|
||||
def test_delete_works(self):
|
||||
self.simulate_delete(self.pool)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
self.simulate_get(self.pool)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
def test_get_nonexisting_raises_404(self):
|
||||
self.simulate_get(self.url_prefix + '/pools/nonexisting')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
def _pool_expect(self, pool, xhref, xweight, xuri):
|
||||
self.assertIn('href', pool)
|
||||
self.assertIn('name', pool)
|
||||
self.assertEqual(pool['href'], xhref)
|
||||
self.assertEqual(xhref, pool['href'])
|
||||
self.assertIn('weight', pool)
|
||||
self.assertEqual(pool['weight'], xweight)
|
||||
self.assertEqual(xweight, pool['weight'])
|
||||
self.assertIn('uri', pool)
|
||||
|
||||
# NOTE(dynarro): we are using startwith because we are adding to
|
||||
@ -173,7 +173,7 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
|
||||
def test_get_works(self):
|
||||
result = self.simulate_get(self.pool)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
pool = jsonutils.loads(result[0])
|
||||
self._pool_expect(pool, self.pool, self.doc['weight'],
|
||||
self.doc['uri'])
|
||||
@ -181,30 +181,30 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
def test_detailed_get_works(self):
|
||||
result = self.simulate_get(self.pool,
|
||||
query_string='detailed=True')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
pool = jsonutils.loads(result[0])
|
||||
self._pool_expect(pool, self.pool, self.doc['weight'],
|
||||
self.doc['uri'])
|
||||
self.assertIn('options', pool)
|
||||
self.assertEqual(pool['options'], {})
|
||||
self.assertEqual({}, pool['options'])
|
||||
|
||||
def test_patch_raises_if_missing_fields(self):
|
||||
self.simulate_patch(self.pool,
|
||||
body=jsonutils.dumps({'location': 1}))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def _patch_test(self, doc):
|
||||
self.simulate_patch(self.pool,
|
||||
body=jsonutils.dumps(doc))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
result = self.simulate_get(self.pool,
|
||||
query_string='detailed=True')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
pool = jsonutils.loads(result[0])
|
||||
self._pool_expect(pool, self.pool, doc['weight'],
|
||||
doc['uri'])
|
||||
self.assertEqual(pool['options'], doc['options'])
|
||||
self.assertEqual(doc['options'], pool['options'])
|
||||
|
||||
def test_patch_works(self):
|
||||
doc = {'weight': 101,
|
||||
@ -223,30 +223,30 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
def test_patch_raises_400_on_invalid_weight(self, weight):
|
||||
self.simulate_patch(self.pool,
|
||||
body=jsonutils.dumps({'weight': weight}))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 2**32+1, [], 'localhost:27017')
|
||||
def test_patch_raises_400_on_invalid_uri(self, uri):
|
||||
self.simulate_patch(self.pool,
|
||||
body=jsonutils.dumps({'uri': uri}))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 'wee', [])
|
||||
def test_patch_raises_400_on_invalid_options(self, options):
|
||||
self.simulate_patch(self.pool,
|
||||
body=jsonutils.dumps({'options': options}))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_patch_raises_404_if_pool_not_found(self):
|
||||
self.simulate_patch(self.url_prefix + '/pools/notexists',
|
||||
body=jsonutils.dumps({'weight': 1}))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
def test_empty_listing(self):
|
||||
self.simulate_delete(self.pool)
|
||||
result = self.simulate_get(self.url_prefix + '/pools')
|
||||
results = jsonutils.loads(result[0])
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
self.assertTrue(len(results['pools']) == 0)
|
||||
self.assertIn('links', results)
|
||||
|
||||
@ -262,7 +262,7 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
with pools(self, count, self.doc['uri']) as expected:
|
||||
result = self.simulate_get(self.url_prefix + '/pools',
|
||||
query_string=query)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
results = jsonutils.loads(result[0])
|
||||
self.assertIsInstance(results, dict)
|
||||
self.assertIn('pools', results)
|
||||
@ -273,28 +273,28 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
self.assertEqual('next', link['rel'])
|
||||
href = falcon.uri.parse_query_string(link['href'].split('?')[1])
|
||||
self.assertIn('marker', href)
|
||||
self.assertEqual(href['limit'], str(limit))
|
||||
self.assertEqual(href['detailed'], str(detailed).lower())
|
||||
self.assertEqual(str(limit), href['limit'])
|
||||
self.assertEqual(str(detailed).lower(), href['detailed'])
|
||||
|
||||
next_query_string = ('marker={marker}&limit={limit}'
|
||||
'&detailed={detailed}').format(**href)
|
||||
next_result = self.simulate_get(link['href'].split('?')[0],
|
||||
query_string=next_query_string)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
next_pool = jsonutils.loads(next_result[0])
|
||||
next_pool_list = next_pool['pools']
|
||||
|
||||
self.assertIn('links', next_pool)
|
||||
if limit < count:
|
||||
self.assertEqual(len(next_pool_list),
|
||||
min(limit, count-limit))
|
||||
self.assertEqual(min(limit, count-limit),
|
||||
len(next_pool_list))
|
||||
else:
|
||||
# NOTE(jeffrey4l): when limit >= count, there will be no
|
||||
# pools in the 2nd page.
|
||||
self.assertTrue(len(next_pool_list) == 0)
|
||||
|
||||
self.assertEqual(len(pool_list), min(limit, count))
|
||||
self.assertEqual(min(limit, count), len(pool_list))
|
||||
for s in pool_list + next_pool_list:
|
||||
# NOTE(flwang): It can't assumed that both sqlalchemy and
|
||||
# mongodb can return query result with the same order. Just
|
||||
@ -307,7 +307,7 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
self._pool_expect(s, path, weight, self.doc['uri'])
|
||||
if detailed:
|
||||
self.assertIn('options', s)
|
||||
self.assertEqual(s['options'], expect[-1])
|
||||
self.assertEqual(expect[-1], s['options'])
|
||||
else:
|
||||
self.assertNotIn('options', s)
|
||||
|
||||
@ -327,8 +327,8 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
with pools(self, 10, self.doc['uri']) as expected:
|
||||
result = self.simulate_get(self.url_prefix + '/pools',
|
||||
query_string='marker=3')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
pool_list = jsonutils.loads(result[0])['pools']
|
||||
self.assertEqual(len(pool_list), 6)
|
||||
self.assertEqual(6, len(pool_list))
|
||||
path, weight = expected[4][:2]
|
||||
self._pool_expect(pool_list[0], path, weight, self.doc['uri'])
|
||||
|
@ -48,16 +48,16 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
|
||||
def test_empty_project_id(self):
|
||||
self.simulate_get(self.gumshoe_queue_path, '')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_put(self.gumshoe_queue_path, '')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_head(self.gumshoe_queue_path, '')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_delete(self.gumshoe_queue_path, '')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data('480924', 'foo', None)
|
||||
def test_basics_thoroughly(self, project_id):
|
||||
@ -66,77 +66,77 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
|
||||
# Stats not found - queue not created yet
|
||||
self.simulate_get(gumshoe_queue_path_stats, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Metadata not found - queue not created yet
|
||||
self.simulate_get(gumshoe_queue_path_metadata, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Create
|
||||
self.simulate_put(self.gumshoe_queue_path, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
location = self.srmock.headers_dict['Location']
|
||||
self.assertEqual(location, self.gumshoe_queue_path)
|
||||
self.assertEqual(self.gumshoe_queue_path, location)
|
||||
|
||||
# Ensure queue existence
|
||||
self.simulate_head(self.gumshoe_queue_path, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Add metadata
|
||||
doc = '{"messages": {"ttl": 600}}'
|
||||
self.simulate_put(gumshoe_queue_path_metadata,
|
||||
project_id, body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Fetch metadata
|
||||
result = self.simulate_get(gumshoe_queue_path_metadata,
|
||||
project_id)
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(result_doc, jsonutils.loads(doc))
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
self.assertEqual(jsonutils.loads(doc), result_doc)
|
||||
|
||||
# Stats empty queue
|
||||
self.simulate_get(gumshoe_queue_path_stats, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
# Delete
|
||||
self.simulate_delete(self.gumshoe_queue_path, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Get non-existent queue
|
||||
self.simulate_get(self.gumshoe_queue_path, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Get non-existent stats
|
||||
self.simulate_get(gumshoe_queue_path_stats, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
# Get non-existent metadata
|
||||
self.simulate_get(gumshoe_queue_path_metadata, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
def test_name_restrictions(self):
|
||||
self.simulate_put(self.queue_path + '/Nice-Boat_2')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
self.simulate_put(self.queue_path + '/Nice-Bo@t')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_put(self.queue_path + '/_' + 'niceboat' * 8)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_project_id_restriction(self):
|
||||
muvluv_queue_path = self.queue_path + '/Muv-Luv'
|
||||
|
||||
self.simulate_put(muvluv_queue_path,
|
||||
headers={'X-Project-ID': 'JAM Project' * 24})
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
# no charset restrictions
|
||||
self.simulate_put(muvluv_queue_path,
|
||||
headers={'X-Project-ID': 'JAM Project'})
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def test_non_ascii_name(self):
|
||||
test_params = ((u'/queues/non-ascii-n\u0153me', 'utf-8'),
|
||||
@ -149,36 +149,36 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
uri = uri.encode(enc)
|
||||
|
||||
self.simulate_put(uri)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_get(uri)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_delete(uri)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_no_metadata(self):
|
||||
self.simulate_put(self.fizbat_queue_path)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
self.simulate_put(self.fizbat_queue_path_metadata)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
self.simulate_put(self.fizbat_queue_path_metadata, body='')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data('{', '[]', '.', ' ', '')
|
||||
def test_bad_metadata(self, document):
|
||||
self.simulate_put(self.fizbat_queue_path, '7e55e1a7e')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
self.simulate_put(self.fizbat_queue_path_metadata, '7e55e1a7e',
|
||||
body=document)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_too_much_metadata(self):
|
||||
self.simulate_put(self.fizbat_queue_path, '7e55e1a7e')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
doc = '{{"messages": {{"ttl": 600}}, "padding": "{pad}"}}'
|
||||
|
||||
max_size = self.transport_cfg.max_queue_metadata
|
||||
@ -188,11 +188,11 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
|
||||
self.simulate_put(self.fizbat_queue_path_metadata, '7e55e1a7e',
|
||||
body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_way_too_much_metadata(self):
|
||||
self.simulate_put(self.fizbat_queue_path, '7e55e1a7e')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
doc = '{{"messages": {{"ttl": 600}}, "padding": "{pad}"}}'
|
||||
|
||||
max_size = self.transport_cfg.max_queue_metadata
|
||||
@ -202,11 +202,11 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
|
||||
self.simulate_put(self.fizbat_queue_path_metadata,
|
||||
'7e55e1a7e', body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_custom_metadata(self):
|
||||
self.simulate_put(self.fizbat_queue_path, '480924')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
# Set
|
||||
doc = '{{"messages": {{"ttl": 600}}, "padding": "{pad}"}}'
|
||||
@ -216,13 +216,13 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
|
||||
doc = doc.format(pad='x' * padding_len)
|
||||
self.simulate_put(self.fizbat_queue_path_metadata, '480924', body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Get
|
||||
result = self.simulate_get(self.fizbat_queue_path_metadata, '480924')
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
self.assertEqual(result_doc, jsonutils.loads(doc))
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(jsonutils.loads(doc), result_doc)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
def test_update_metadata(self):
|
||||
xyz_queue_path = self.url_prefix + '/queues/xyz'
|
||||
@ -231,25 +231,25 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
# Create
|
||||
project_id = '480924'
|
||||
self.simulate_put(xyz_queue_path, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
# Set meta
|
||||
doc1 = '{"messages": {"ttl": 600}}'
|
||||
self.simulate_put(xyz_queue_path_metadata, project_id, body=doc1)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Update
|
||||
doc2 = '{"messages": {"ttl": 100}}'
|
||||
self.simulate_put(xyz_queue_path_metadata, project_id, body=doc2)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Get
|
||||
result = self.simulate_get(xyz_queue_path_metadata, project_id)
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
|
||||
self.assertEqual(result_doc, jsonutils.loads(doc2))
|
||||
self.assertEqual(self.srmock.headers_dict['Content-Location'],
|
||||
xyz_queue_path_metadata)
|
||||
self.assertEqual(jsonutils.loads(doc2), result_doc)
|
||||
self.assertEqual(xyz_queue_path_metadata,
|
||||
self.srmock.headers_dict['Content-Location'])
|
||||
|
||||
def test_list(self):
|
||||
arbitrary_number = 644079696574693
|
||||
@ -262,11 +262,11 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
|
||||
# List empty
|
||||
self.simulate_get(self.queue_path, project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Payload exceeded
|
||||
self.simulate_get(self.queue_path, project_id, query_string='limit=21')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
# Create some
|
||||
def create_queue(name, project_id, body):
|
||||
@ -289,17 +289,17 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
queues = result_doc['queues']
|
||||
self.assertEqual(len(queues), 2)
|
||||
self.assertEqual(2, len(queues))
|
||||
|
||||
for queue in queues:
|
||||
self.assertEqual(queue['metadata'], {'answer': 42})
|
||||
self.assertEqual({'answer': 42}, queue['metadata'])
|
||||
|
||||
# List (limit)
|
||||
result = self.simulate_get(self.queue_path, project_id,
|
||||
query_string='limit=2')
|
||||
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
self.assertEqual(len(result_doc['queues']), 2)
|
||||
self.assertEqual(2, len(result_doc['queues']))
|
||||
|
||||
# List (no metadata, get all)
|
||||
result = self.simulate_get(self.queue_path,
|
||||
@ -308,20 +308,20 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
[target, params] = result_doc['links'][0]['href'].split('?')
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(self.srmock.headers_dict['Content-Location'],
|
||||
self.queue_path + '?limit=5')
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
self.assertEqual(self.queue_path + '?limit=5',
|
||||
self.srmock.headers_dict['Content-Location'])
|
||||
|
||||
# Ensure we didn't pick up the queue from the alt project.
|
||||
queues = result_doc['queues']
|
||||
self.assertEqual(len(queues), 3)
|
||||
self.assertEqual(3, len(queues))
|
||||
|
||||
for queue in queues:
|
||||
self.simulate_get(queue['href'] + '/metadata', project_id)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
self.simulate_get(queue['href'] + '/metadata', 'imnothere')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_404)
|
||||
self.assertEqual(falcon.HTTP_404, self.srmock.status)
|
||||
|
||||
self.assertNotIn('metadata', queue)
|
||||
|
||||
@ -329,23 +329,23 @@ class TestQueueLifecycleMongoDB(base.V1Base):
|
||||
result = self.simulate_get(self.queue_path, project_id,
|
||||
query_string='detailed=true')
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_200)
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
[target, params] = result_doc['links'][0]['href'].split('?')
|
||||
|
||||
queue = result_doc['queues'][0]
|
||||
result = self.simulate_get(queue['href'] + '/metadata', project_id)
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
self.assertEqual(result_doc, queue['metadata'])
|
||||
self.assertEqual(result_doc, {'node': 31})
|
||||
self.assertEqual(queue['metadata'], result_doc)
|
||||
self.assertEqual({'node': 31}, result_doc)
|
||||
|
||||
# List tail
|
||||
self.simulate_get(target, project_id, query_string=params)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# List manually-constructed tail
|
||||
self.simulate_get(target, project_id, query_string='marker=zzz')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
|
||||
class TestQueueLifecycleFaultyDriver(base.V1BaseFaulty):
|
||||
@ -356,21 +356,21 @@ class TestQueueLifecycleFaultyDriver(base.V1BaseFaulty):
|
||||
gumshoe_queue_path = self.url_prefix + '/queues/gumshoe'
|
||||
doc = '{"messages": {"ttl": 600}}'
|
||||
self.simulate_put(gumshoe_queue_path, '480924', body=doc)
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
location = ('Location', gumshoe_queue_path)
|
||||
self.assertNotIn(location, self.srmock.headers)
|
||||
|
||||
result = self.simulate_get(gumshoe_queue_path + '/metadata', '480924')
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
self.assertNotEqual(result_doc, jsonutils.loads(doc))
|
||||
|
||||
self.simulate_get(gumshoe_queue_path + '/stats', '480924')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
self.simulate_get(self.url_prefix + '/queues', '480924')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
||||
self.simulate_delete(gumshoe_queue_path, '480924')
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_503)
|
||||
self.assertEqual(falcon.HTTP_503, self.srmock.status)
|
||||
|
@ -47,7 +47,7 @@ class TestValidation(base.V1Base):
|
||||
self.project_id,
|
||||
body='{"timespace": "Shangri-la"}')
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_204)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
# Too long
|
||||
max_queue_metadata = 64
|
||||
@ -63,7 +63,7 @@ class TestValidation(base.V1Base):
|
||||
self.project_id,
|
||||
body=doc)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_message_deserialization(self):
|
||||
# Normal case
|
||||
@ -72,7 +72,7 @@ class TestValidation(base.V1Base):
|
||||
body='[{"body": "Dragon Knights", "ttl": 100}]',
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_201)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
# Both messages' size are too long
|
||||
max_messages_post_size = 256
|
||||
@ -88,4 +88,4 @@ class TestValidation(base.V1Base):
|
||||
body=doc,
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_400)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
Loading…
Reference in New Issue
Block a user