Fixed web related tests

This commit is contained in:
Rodolphe Marques 2017-06-13 12:31:49 +02:00
parent 7ffea9e8a4
commit 05a6653d5f
2 changed files with 18 additions and 18 deletions

View File

@ -41,7 +41,7 @@ def test_get_blocks_by_txid_endpoint(b, client):
block_invalid = b.create_block([tx])
b.write_block(block_invalid)
res = client.get(BLOCKS_ENDPOINT + '?tx_id=' + tx.id)
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=' + tx.id)
# test if block is retrieved as undecided
assert res.status_code == 200
assert block_invalid.id in res.json
@ -51,7 +51,7 @@ def test_get_blocks_by_txid_endpoint(b, client):
vote = b.vote(block_invalid.id, b.get_last_voted_block().id, False)
b.write_vote(vote)
res = client.get(BLOCKS_ENDPOINT + '?tx_id=' + tx.id)
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=' + tx.id)
# test if block is retrieved as invalid
assert res.status_code == 200
assert block_invalid.id in res.json
@ -61,7 +61,7 @@ def test_get_blocks_by_txid_endpoint(b, client):
block_valid = b.create_block([tx, tx2])
b.write_block(block_valid)
res = client.get(BLOCKS_ENDPOINT + '?tx_id=' + tx.id)
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=' + tx.id)
# test if block is retrieved as undecided
assert res.status_code == 200
assert block_valid.id in res.json
@ -71,7 +71,7 @@ def test_get_blocks_by_txid_endpoint(b, client):
vote = b.vote(block_valid.id, block_invalid.id, True)
b.write_vote(vote)
res = client.get(BLOCKS_ENDPOINT + '?tx_id=' + tx.id)
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=' + tx.id)
# test if block is retrieved as valid
assert res.status_code == 200
assert block_valid.id in res.json
@ -96,19 +96,19 @@ 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, Bigchain.BLOCK_INVALID))
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_INVALID))
# test if no blocks are retrieved as invalid
assert res.status_code == 200
assert len(res.json) == 0
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_UNDECIDED))
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_UNDECIDED))
# test if both blocks are retrieved as undecided
assert res.status_code == 200
assert block_valid.id in res.json
assert block_invalid.id in res.json
assert len(res.json) == 2
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
# test if no blocks are retrieved as valid
assert res.status_code == 200
assert len(res.json) == 0
@ -121,18 +121,18 @@ 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, Bigchain.BLOCK_INVALID))
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_INVALID))
# test if the invalid 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, Bigchain.BLOCK_UNDECIDED))
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_UNDECIDED))
# test if no blocks are retrieved as undecided
assert res.status_code == 200
assert len(res.json) == 0
res = client.get('{}?tx_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
res = client.get('{}?transaction_id={}&status={}'.format(BLOCKS_ENDPOINT, tx.id, Bigchain.BLOCK_VALID))
# test if the valid block is retrieved as valid
assert res.status_code == 200
assert block_valid.id in res.json
@ -141,11 +141,11 @@ def test_get_blocks_by_txid_and_status_endpoint(b, client):
@pytest.mark.bdb
def test_get_blocks_by_txid_endpoint_returns_empty_list_not_found(client):
res = client.get(BLOCKS_ENDPOINT + '?tx_id=')
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=')
assert res.status_code == 200
assert len(res.json) == 0
res = client.get(BLOCKS_ENDPOINT + '?tx_id=123')
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123')
assert res.status_code == 200
assert len(res.json) == 0
@ -159,17 +159,17 @@ def test_get_blocks_by_txid_endpoint_returns_400_bad_query_params(client):
assert res.status_code == 400
assert res.json == {
'message': {
'tx_id': 'Missing required parameter in the JSON body or the post body or the query string'
'transaction_id': 'Missing required parameter in the JSON body or the post body or the query string'
}
}
res = client.get(BLOCKS_ENDPOINT + '?tx_id=123&foo=123')
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&foo=123')
assert res.status_code == 400
assert res.json == {
'message': 'Unknown arguments: foo'
}
res = client.get(BLOCKS_ENDPOINT + '?tx_id=123&status=123')
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&status=123')
assert res.status_code == 400
assert res.json == {
'message': {

View File

@ -10,7 +10,7 @@ STATUSES_ENDPOINT = '/api/v1/statuses'
def test_get_transaction_status_endpoint(b, client, user_pk):
input_tx = b.get_owned_ids(user_pk).pop()
tx, status = b.get_transaction(input_tx.txid, include_status=True)
res = client.get(STATUSES_ENDPOINT + '?tx_id=' + input_tx.txid)
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
@ -18,7 +18,7 @@ def test_get_transaction_status_endpoint(b, client, user_pk):
@pytest.mark.bdb
def test_get_transaction_status_endpoint_returns_404_if_not_found(client):
res = client.get(STATUSES_ENDPOINT + '?tx_id=123')
res = client.get(STATUSES_ENDPOINT + '?transaction_id=123')
assert res.status_code == 404
@ -94,5 +94,5 @@ def test_get_status_endpoint_returns_400_bad_query_params(client):
res = client.get(STATUSES_ENDPOINT + '?ts_id=123')
assert res.status_code == 400
res = client.get(STATUSES_ENDPOINT + '?tx_id=123&block_id=123')
res = client.get(STATUSES_ENDPOINT + '?transaction_id=123&block_id=123')
assert res.status_code == 400