Return 404 when tx not found

This commit is contained in:
vrde 2016-06-08 09:39:40 -07:00
parent 591f218c23
commit 0c35e9abff
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
2 changed files with 10 additions and 1 deletions

View File

@ -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)

View File

@ -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()