Merge "API v1.1: adding id field to messages"
This commit is contained in:
commit
83e57a6324
@ -31,6 +31,9 @@ class ResponseSchema(api.Api):
|
|||||||
message = {
|
message = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"href": {
|
"href": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^(/v1\.1/queues/[a-zA-Z0-9_-]"
|
"pattern": "^(/v1\.1/queues/[a-zA-Z0-9_-]"
|
||||||
@ -47,7 +50,7 @@ class ResponseSchema(api.Api):
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["href", "ttl", "age", "body"],
|
"required": ["href", "ttl", "age", "body", "id"],
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,6 @@ class CollectionResource(object):
|
|||||||
base_path += '/'
|
base_path += '/'
|
||||||
for each_message in messages:
|
for each_message in messages:
|
||||||
each_message['href'] = base_path + each_message['id']
|
each_message['href'] = base_path + each_message['id']
|
||||||
del each_message['id']
|
|
||||||
|
|
||||||
return {'messages': messages}
|
return {'messages': messages}
|
||||||
|
|
||||||
@ -129,7 +128,6 @@ class CollectionResource(object):
|
|||||||
kwargs['marker'] = next(results)
|
kwargs['marker'] = next(results)
|
||||||
for each_message in messages:
|
for each_message in messages:
|
||||||
each_message['href'] = req.path + '/' + each_message['id']
|
each_message['href'] = req.path + '/' + each_message['id']
|
||||||
del each_message['id']
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'messages': messages,
|
'messages': messages,
|
||||||
@ -331,7 +329,6 @@ class ItemResource(object):
|
|||||||
|
|
||||||
# Prepare response
|
# Prepare response
|
||||||
message['href'] = req.path
|
message['href'] = req.path
|
||||||
del message['id']
|
|
||||||
|
|
||||||
resp.content_location = req.relative_uri
|
resp.content_location = req.relative_uri
|
||||||
resp.body = utils.to_json(message)
|
resp.body = utils.to_json(message)
|
||||||
|
@ -118,6 +118,7 @@ class MessagesBaseTest(base.V1_1Base):
|
|||||||
message = jsonutils.loads(result[0])
|
message = jsonutils.loads(result[0])
|
||||||
self.assertEqual(message['href'], message_uri)
|
self.assertEqual(message['href'], message_uri)
|
||||||
self.assertEqual(message['body'], lookup[message['ttl']])
|
self.assertEqual(message['body'], lookup[message['ttl']])
|
||||||
|
self.assertEqual(msg_id, message['id'])
|
||||||
|
|
||||||
# no negative age
|
# no negative age
|
||||||
# NOTE(cpp-cabrera): testtools lacks GreaterThanEqual on py26
|
# NOTE(cpp-cabrera): testtools lacks GreaterThanEqual on py26
|
||||||
@ -135,6 +136,8 @@ class MessagesBaseTest(base.V1_1Base):
|
|||||||
expected_ttls = set(m['ttl'] for m in sample_messages)
|
expected_ttls = set(m['ttl'] for m in sample_messages)
|
||||||
actual_ttls = set(m['ttl'] for m in result_doc['messages'])
|
actual_ttls = set(m['ttl'] for m in result_doc['messages'])
|
||||||
self.assertFalse(expected_ttls - actual_ttls)
|
self.assertFalse(expected_ttls - actual_ttls)
|
||||||
|
actual_ids = set(m['id'] for m in result_doc['messages'])
|
||||||
|
self.assertFalse(set(msg_ids) - actual_ids)
|
||||||
|
|
||||||
def test_exceeded_payloads(self):
|
def test_exceeded_payloads(self):
|
||||||
# Get a valid message id
|
# Get a valid message id
|
||||||
|
Loading…
Reference in New Issue
Block a user