2018-08-16 12:31:32 +02:00
|
|
|
# Copyright BigchainDB GmbH and BigchainDB contributors
|
|
|
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
|
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
|
2017-01-10 14:41:02 +01:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
BLOCKS_ENDPOINT = '/api/v1/blocks/'
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.bdb
|
|
|
|
@pytest.mark.usefixtures('inputs')
|
|
|
|
def test_get_block_returns_404_if_not_found(client):
|
|
|
|
res = client.get(BLOCKS_ENDPOINT + '123')
|
|
|
|
assert res.status_code == 404
|
|
|
|
|
|
|
|
res = client.get(BLOCKS_ENDPOINT + '123/')
|
|
|
|
assert res.status_code == 404
|
|
|
|
|
|
|
|
|
2017-01-13 18:24:31 +01:00
|
|
|
@pytest.mark.bdb
|
|
|
|
def test_get_blocks_by_txid_endpoint_returns_empty_list_not_found(client):
|
2017-06-13 12:31:49 +02:00
|
|
|
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=')
|
2017-01-13 18:24:31 +01:00
|
|
|
assert res.status_code == 200
|
|
|
|
assert len(res.json) == 0
|
|
|
|
|
2017-06-13 12:31:49 +02:00
|
|
|
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123')
|
2017-01-13 18:24:31 +01:00
|
|
|
assert res.status_code == 200
|
|
|
|
assert len(res.json) == 0
|
|
|
|
|
|
|
|
|
2017-01-10 14:41:02 +01:00
|
|
|
@pytest.mark.bdb
|
|
|
|
def test_get_blocks_by_txid_endpoint_returns_400_bad_query_params(client):
|
|
|
|
res = client.get(BLOCKS_ENDPOINT)
|
|
|
|
assert res.status_code == 400
|
|
|
|
|
2017-01-23 17:30:37 +01:00
|
|
|
res = client.get(BLOCKS_ENDPOINT + '?ts_id=123')
|
2017-01-10 14:41:02 +01:00
|
|
|
assert res.status_code == 400
|
2017-01-11 18:44:21 +01:00
|
|
|
assert res.json == {
|
|
|
|
'message': {
|
2017-06-13 12:31:49 +02:00
|
|
|
'transaction_id': 'Missing required parameter in the JSON body or the post body or the query string'
|
2017-01-11 18:44:21 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-10 14:41:02 +01:00
|
|
|
|
2017-06-13 12:31:49 +02:00
|
|
|
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&foo=123')
|
2017-01-10 14:41:02 +01:00
|
|
|
assert res.status_code == 400
|
2017-01-11 18:44:21 +01:00
|
|
|
assert res.json == {
|
|
|
|
'message': 'Unknown arguments: foo'
|
|
|
|
}
|
|
|
|
|
2017-06-13 12:31:49 +02:00
|
|
|
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&status=123')
|
2017-01-11 18:44:21 +01:00
|
|
|
assert res.status_code == 400
|
|
|
|
assert res.json == {
|
2018-09-10 09:53:18 +02:00
|
|
|
'message': 'Unknown arguments: status'
|
2017-01-11 18:44:21 +01:00
|
|
|
}
|