Return 404 when tx not found
This commit is contained in:
parent
591f218c23
commit
0c35e9abff
|
@ -5,7 +5,7 @@ For more information please refer to the documentation in Apiary:
|
|||
"""
|
||||
|
||||
import flask
|
||||
from flask import current_app, request, Blueprint
|
||||
from flask import abort, current_app, request, Blueprint
|
||||
|
||||
import bigchaindb
|
||||
from bigchaindb import util
|
||||
|
@ -51,6 +51,9 @@ def get_transaction(tx_id):
|
|||
with pool() as bigchain:
|
||||
tx = bigchain.get_transaction(tx_id)
|
||||
|
||||
if not tx:
|
||||
abort(404)
|
||||
|
||||
return flask.jsonify(**tx)
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@ def test_get_transaction_endpoint(b, client, user_vk):
|
|||
assert tx == res.json
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_transaction_returns_404_if_not_found(client):
|
||||
res = client.get(TX_ENDPOINT + '123')
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
def test_post_create_transaction_endpoint(b, client):
|
||||
keypair = crypto.generate_key_pair()
|
||||
|
||||
|
|
Loading…
Reference in New Issue