From 1b6d0adc01a6bb9a8df66083abf0cd65d4e41dbd Mon Sep 17 00:00:00 2001 From: Troy McConaghy Date: Mon, 19 Feb 2018 12:04:10 +0100 Subject: [PATCH] removed code for all /statuses endpoints --- bigchaindb/web/routes.py | 2 - bigchaindb/web/views/info.py | 1 - bigchaindb/web/views/statuses.py | 45 --------------- tests/web/test_info.py | 2 - tests/web/test_statuses.py | 94 -------------------------------- tests/web/test_transactions.py | 3 - 6 files changed, 147 deletions(-) delete mode 100644 bigchaindb/web/views/statuses.py delete mode 100644 tests/web/test_statuses.py diff --git a/bigchaindb/web/routes.py b/bigchaindb/web/routes.py index b5fd8eb3..5b6185ba 100644 --- a/bigchaindb/web/routes.py +++ b/bigchaindb/web/routes.py @@ -5,7 +5,6 @@ from bigchaindb.web.views import ( metadata, blocks, info, - statuses, transactions as tx, outputs, votes, @@ -31,7 +30,6 @@ ROUTES_API_V1 = [ r('metadata/', metadata.MetadataApi), r('blocks/', blocks.BlockApi), r('blocks/', blocks.BlockListApi), - r('statuses/', statuses.StatusApi), r('transactions/', tx.TransactionApi), r('transactions', tx.TransactionListApi), r('outputs/', outputs.OutputListApi), diff --git a/bigchaindb/web/views/info.py b/bigchaindb/web/views/info.py index d6162a34..205f4930 100644 --- a/bigchaindb/web/views/info.py +++ b/bigchaindb/web/views/info.py @@ -46,7 +46,6 @@ def get_api_v1_info(api_prefix): return { 'docs': ''.join(docs_url), 'transactions': '{}transactions/'.format(api_prefix), - 'statuses': '{}statuses/'.format(api_prefix), 'assets': '{}assets/'.format(api_prefix), 'outputs': '{}outputs/'.format(api_prefix), 'streams': websocket_root, diff --git a/bigchaindb/web/views/statuses.py b/bigchaindb/web/views/statuses.py deleted file mode 100644 index 0044c334..00000000 --- a/bigchaindb/web/views/statuses.py +++ /dev/null @@ -1,45 +0,0 @@ -"""This module provides the blueprint for the statuses API endpoints. - -For more information please refer to the documentation: http://bigchaindb.com/http-api -""" -from flask import current_app -from flask_restful import Resource, reqparse - -from bigchaindb.web.views.base import make_error - - -class StatusApi(Resource): - def get(self): - """API endpoint to get details about the status of a transaction or a block. - - Return: - A ``dict`` in the format ``{'status': }``, where - ```` is one of "valid", "invalid", "undecided", "backlog". - """ - parser = reqparse.RequestParser() - parser.add_argument('transaction_id', type=str) - parser.add_argument('block_id', type=str) - - args = parser.parse_args(strict=True) - tx_id = args['transaction_id'] - block_id = args['block_id'] - - # logical xor - exactly one query argument required - if bool(tx_id) == bool(block_id): - return make_error(400, 'Provide exactly one query parameter. Choices are: block_id, transaction_id') - - pool = current_app.config['bigchain_pool'] - status = None - - with pool() as bigchain: - if tx_id: - status = bigchain.get_status(tx_id) - elif block_id: - _, status = bigchain.get_block(block_id=block_id, include_status=True) - - if not status: - return make_error(404) - - return { - 'status': status - } diff --git a/tests/web/test_info.py b/tests/web/test_info.py index 459f3e05..f682b5e3 100644 --- a/tests/web/test_info.py +++ b/tests/web/test_info.py @@ -13,7 +13,6 @@ def test_api_root_endpoint(client, wsserver_base_url): 'v1': { 'docs': ''.join(docs_url), 'transactions': '/api/v1/transactions/', - 'statuses': '/api/v1/statuses/', 'assets': '/api/v1/assets/', 'outputs': '/api/v1/outputs/', 'streams': '{}/api/v1/streams/valid_transactions'.format( @@ -37,7 +36,6 @@ def test_api_v1_endpoint(client, wsserver_base_url): api_v1_info = { 'docs': ''.join(docs_url), 'transactions': '/transactions/', - 'statuses': '/statuses/', 'assets': '/assets/', 'outputs': '/outputs/', 'streams': '{}/api/v1/streams/valid_transactions'.format( diff --git a/tests/web/test_statuses.py b/tests/web/test_statuses.py deleted file mode 100644 index 7c2a7c14..00000000 --- a/tests/web/test_statuses.py +++ /dev/null @@ -1,94 +0,0 @@ -import pytest - -from bigchaindb.models import Transaction - -STATUSES_ENDPOINT = '/api/v1/statuses' - - -@pytest.mark.bdb -@pytest.mark.usefixtures('inputs') -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 + '?transaction_id=' + input_tx.txid) - assert status == res.json['status'] - assert res.status_code == 200 - - -@pytest.mark.bdb -def test_get_transaction_status_endpoint_returns_404_if_not_found(client): - res = client.get(STATUSES_ENDPOINT + '?transaction_id=123') - assert res.status_code == 404 - - -@pytest.mark.bdb -def test_get_block_status_endpoint_undecided(b, client): - tx = Transaction.create([b.me], [([b.me], 1)]) - tx = tx.sign([b.me_private]) - - block = b.create_block([tx]) - b.write_block(block) - - status = b.block_election_status(block) - - res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id) - assert status == res.json['status'] - assert res.status_code == 200 - - -@pytest.mark.bdb -@pytest.mark.usefixtures('inputs') -def test_get_block_status_endpoint_valid(b, client): - tx = Transaction.create([b.me], [([b.me], 1)]) - tx = tx.sign([b.me_private]) - - block = b.create_block([tx]) - b.write_block(block) - - # vote the block valid - vote = b.vote(block.id, b.get_last_voted_block().id, True) - b.write_vote(vote) - - status = b.block_election_status(block) - - res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id) - assert status == res.json['status'] - assert res.status_code == 200 - - -@pytest.mark.bdb -@pytest.mark.usefixtures('inputs') -def test_get_block_status_endpoint_invalid(b, client): - tx = Transaction.create([b.me], [([b.me], 1)]) - tx = tx.sign([b.me_private]) - - block = b.create_block([tx]) - b.write_block(block) - - # vote the block valid - vote = b.vote(block.id, b.get_last_voted_block().id, False) - b.write_vote(vote) - - status = b.block_election_status(block) - - res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id) - assert status == res.json['status'] - assert res.status_code == 200 - - -@pytest.mark.bdb -def test_get_block_status_endpoint_returns_404_if_not_found(client): - res = client.get(STATUSES_ENDPOINT + '?block_id=123') - assert res.status_code == 404 - - -@pytest.mark.bdb -def test_get_status_endpoint_returns_400_bad_query_params(client): - res = client.get(STATUSES_ENDPOINT) - assert res.status_code == 400 - - res = client.get(STATUSES_ENDPOINT + '?ts_id=123') - assert res.status_code == 400 - - res = client.get(STATUSES_ENDPOINT + '?transaction_id=123&block_id=123') - assert res.status_code == 400 diff --git a/tests/web/test_transactions.py b/tests/web/test_transactions.py index a67d790e..f376bf09 100644 --- a/tests/web/test_transactions.py +++ b/tests/web/test_transactions.py @@ -44,9 +44,6 @@ def test_post_create_transaction_endpoint(b, client): assert res.status_code == 202 - assert '../statuses?transaction_id={}'.format(tx.id) in \ - res.headers['Location'] - assert res.json['inputs'][0]['owners_before'][0] == user_pub assert res.json['outputs'][0]['public_keys'][0] == user_pub