mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Remove links from statuses endpoint
- Updated documentation - Updated tests
This commit is contained in:
parent
446e454a77
commit
4d1131d90c
@ -29,32 +29,17 @@ class StatusApi(Resource):
|
||||
return make_error(400, 'Provide exactly one query parameter. Choices are: block_id, tx_id')
|
||||
|
||||
pool = current_app.config['bigchain_pool']
|
||||
status, links = None, None
|
||||
status = None
|
||||
|
||||
with pool() as bigchain:
|
||||
if tx_id:
|
||||
status = bigchain.get_status(tx_id)
|
||||
links = {
|
||||
'tx': '/transactions/{}'.format(tx_id)
|
||||
}
|
||||
|
||||
elif block_id:
|
||||
_, status = bigchain.get_block(block_id=block_id, include_status=True)
|
||||
# TODO: enable once blocks endpoint is available
|
||||
# links = {
|
||||
# "block": "/blocks/{}".format(args['block_id'])
|
||||
# }
|
||||
|
||||
if not status:
|
||||
return make_error(404)
|
||||
|
||||
response = {
|
||||
return {
|
||||
'status': status
|
||||
}
|
||||
|
||||
if links:
|
||||
response.update({
|
||||
'_links': links
|
||||
})
|
||||
|
||||
return response
|
||||
|
@ -97,10 +97,7 @@ HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"status": "valid",
|
||||
"_links": {
|
||||
"tx": "/transactions/%(txid)s"
|
||||
}
|
||||
"status": "valid"
|
||||
}
|
||||
"""
|
||||
|
||||
@ -127,10 +124,7 @@ HTTP/1.1 200 OK
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"status": "valid",
|
||||
"_links": {
|
||||
"block": "/blocks/%(blockid)s"
|
||||
}
|
||||
"status": "valid"
|
||||
}
|
||||
"""
|
||||
|
||||
|
@ -218,9 +218,6 @@ Statuses
|
||||
|
||||
Get the status of an asynchronously written transaction or block by their id.
|
||||
|
||||
A link to the resource is also provided in the returned payload under
|
||||
``_links``.
|
||||
|
||||
:query string transaction_id: transaction ID
|
||||
:query string block_id: block ID
|
||||
|
||||
@ -252,7 +249,6 @@ Statuses
|
||||
:language: http
|
||||
|
||||
:resheader Content-Type: ``application/json``
|
||||
:resheader Location: Once the transaction has been persisted, this header will link to the actual resource.
|
||||
|
||||
:statuscode 200: A transaction with that ID was found.
|
||||
:statuscode 404: A transaction with that ID was not found.
|
||||
@ -271,16 +267,10 @@ Statuses
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. literalinclude:: http-samples/get-statuses-block-invalid-response.http
|
||||
:language: http
|
||||
|
||||
**Example response**:
|
||||
|
||||
.. literalinclude:: http-samples/get-statuses-block-valid-response.http
|
||||
:language: http
|
||||
|
||||
:resheader Content-Type: ``application/json``
|
||||
:resheader Location: Once the block has been persisted, this header will link to the actual resource.
|
||||
|
||||
:statuscode 200: A block with that ID was found.
|
||||
:statuscode 404: A block with that ID was not found.
|
||||
|
@ -12,7 +12,6 @@ def test_get_transaction_status_endpoint(b, client, user_pk):
|
||||
tx, status = b.get_transaction(input_tx.txid, include_status=True)
|
||||
res = client.get(STATUSES_ENDPOINT + '?transaction_id=' + input_tx.txid)
|
||||
assert status == res.json['status']
|
||||
assert res.json['_links']['tx'] == '/transactions/{}'.format(input_tx.txid)
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
@ -34,7 +33,6 @@ def test_get_block_status_endpoint_undecided(b, client):
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id)
|
||||
assert status == res.json['status']
|
||||
assert '_links' not in res.json
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
@ -55,7 +53,6 @@ def test_get_block_status_endpoint_valid(b, client):
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id)
|
||||
assert status == res.json['status']
|
||||
assert '_links' not in res.json
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
@ -76,7 +73,6 @@ def test_get_block_status_endpoint_invalid(b, client):
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id)
|
||||
assert status == res.json['status']
|
||||
assert '_links' not in res.json
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user