Merge branch 'return-404-when-tx-not-found'

This commit is contained in:
vrde 2016-06-16 14:59:47 +02:00
commit ba83dfcd42
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 import flask
from flask import current_app, request, Blueprint from flask import abort, current_app, request, Blueprint
import bigchaindb import bigchaindb
from bigchaindb import util from bigchaindb import util
@ -51,6 +51,9 @@ def get_transaction(tx_id):
with pool() as bigchain: with pool() as bigchain:
tx = bigchain.get_transaction(tx_id) tx = bigchain.get_transaction(tx_id)
if not tx:
abort(404)
return flask.jsonify(**tx) return flask.jsonify(**tx)

View File

@ -16,6 +16,12 @@ def test_get_transaction_endpoint(b, client, user_vk):
assert tx == res.json 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): def test_post_create_transaction_endpoint(b, client):
keypair = crypto.generate_key_pair() keypair = crypto.generate_key_pair()