mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
replace status strings by Bigchain attributes
This commit is contained in:
parent
1cc46fb86e
commit
f018a4f6e7
@ -7,6 +7,7 @@ For more information please refer to the documentation on ReadTheDocs:
|
||||
from flask import current_app
|
||||
from flask_restful import Resource, reqparse
|
||||
|
||||
from bigchaindb import Bigchain
|
||||
from bigchaindb.web.views.base import make_error
|
||||
|
||||
|
||||
@ -42,7 +43,8 @@ class BlockListApi(Resource):
|
||||
"""
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument('tx_id', type=str, required=True)
|
||||
parser.add_argument('status', type=str, choices=['valid', 'invalid', 'undecided'])
|
||||
parser.add_argument('status', type=str,
|
||||
choices=[Bigchain.BLOCK_VALID, Bigchain.BLOCK_INVALID, Bigchain.BLOCK_UNDECIDED])
|
||||
|
||||
args = parser.parse_args(strict=True)
|
||||
tx_id = args['tx_id']
|
||||
|
@ -81,6 +81,8 @@ def test_get_blocks_by_txid_endpoint(b, client):
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_blocks_by_txid_and_status_endpoint(b, client):
|
||||
from bigchaindb import Bigchain
|
||||
|
||||
tx = Transaction.create([b.me], [([b.me], 1)])
|
||||
tx = tx.sign([b.me_private])
|
||||
|
||||
@ -98,13 +100,13 @@ def test_get_blocks_by_txid_and_status_endpoint(b, client):
|
||||
block_valid = b.create_block([tx, tx2])
|
||||
b.write_block(block_valid)
|
||||
|
||||
res = client.get("{}?tx_id={}&status={}".format(BLOCKS_ENDPOINT, tx.id, 'invalid'))
|
||||
res = client.get("{}?tx_id={}&status={}".format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_INVALID))
|
||||
# test if block is retrieved as invalid
|
||||
assert res.status_code == 200
|
||||
assert block_invalid.id in res.json
|
||||
assert len(res.json) == 1
|
||||
|
||||
res = client.get("{}?tx_id={}&status={}".format(BLOCKS_ENDPOINT, tx.id, 'undecided'))
|
||||
res = client.get("{}?tx_id={}&status={}".format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_UNDECIDED))
|
||||
# test if block is retrieved as undecided
|
||||
assert res.status_code == 200
|
||||
assert block_valid.id in res.json
|
||||
@ -114,7 +116,7 @@ def test_get_blocks_by_txid_and_status_endpoint(b, client):
|
||||
vote = b.vote(block_valid.id, block_invalid.id, True)
|
||||
b.write_vote(vote)
|
||||
|
||||
res = client.get("{}?tx_id={}&status={}".format(BLOCKS_ENDPOINT, tx.id, 'valid'))
|
||||
res = client.get("{}?tx_id={}&status={}".format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
|
||||
# test if block is retrieved as valid
|
||||
assert res.status_code == 200
|
||||
assert block_valid.id in res.json
|
||||
@ -153,4 +155,3 @@ def test_get_blocks_by_txid_endpoint_returns_400_bad_query_params(client):
|
||||
'status': '123 is not a valid choice'
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user