diff --git a/bigchaindb/web/views/parameters.py b/bigchaindb/web/views/parameters.py index 9968a659..222adb97 100644 --- a/bigchaindb/web/views/parameters.py +++ b/bigchaindb/web/views/parameters.py @@ -17,7 +17,7 @@ def valid_bool(val): def valid_ed25519(key): if (re.match('^[1-9a-zA-Z]{43,44}$', key) and not - re.match('.*[Il0O]', key)): + re.match('.*[Il0O]', key)): return key raise ValueError("Invalid base58 ed25519 key") diff --git a/bigchaindb/web/views/transactions.py b/bigchaindb/web/views/transactions.py index bc828df7..a2b6cd30 100644 --- a/bigchaindb/web/views/transactions.py +++ b/bigchaindb/web/views/transactions.py @@ -5,7 +5,6 @@ For more information please refer to the documentation on ReadTheDocs: http-client-server-api.html """ import logging -import re from flask import current_app, request from flask_restful import Resource, reqparse diff --git a/tests/test_txlist.py b/tests/test_txlist.py index 6f9f203a..e7de8c98 100644 --- a/tests/test_txlist.py +++ b/tests/test_txlist.py @@ -28,9 +28,8 @@ def txlist(b, user_pk, user2_pk, user_sk, user2_sk, genesis_block): b.write_block(block2) # Create block with double spend - tx_doublespend = Transaction.transfer(create1.to_inputs(), - [([user_pk], 9)], - create1.id).sign([user2_sk]) + tx_doublespend = Transaction.transfer(create1.to_inputs(), [([user_pk], 9)], + create1.id).sign([user2_sk]) block_doublespend = b.create_block([tx_doublespend]) b.write_block(block_doublespend) @@ -43,7 +42,7 @@ def txlist(b, user_pk, user2_pk, user_sk, user2_sk, genesis_block): # Create undecided block untx = Transaction.create([user_pk], [([user2_pk], 7)]) \ - .sign([user_sk]) + .sign([user_sk]) block_undecided = b.create_block([untx]) b.write_block(block_undecided) diff --git a/tests/web/test_parameters.py b/tests/web/test_parameters.py index 4044a273..d39c6f38 100644 --- a/tests/web/test_parameters.py +++ b/tests/web/test_parameters.py @@ -22,8 +22,8 @@ def test_valid_txid(): def test_valid_bool(): from bigchaindb.web.views.parameters import valid_bool - assert valid_bool('true') == True - valid_bool('false') == False + assert valid_bool('true') is True + assert valid_bool('false') is False with pytest.raises(ValueError): valid_bool('TRUE') diff --git a/tests/web/test_transactions.py b/tests/web/test_transactions.py index f40bc924..fb0f8cb2 100644 --- a/tests/web/test_transactions.py +++ b/tests/web/test_transactions.py @@ -1,6 +1,6 @@ import builtins import json -from unittest.mock import Mock, patch +from unittest.mock import patch import pytest from bigchaindb.common import crypto @@ -185,6 +185,7 @@ def test_post_invalid_transfer_transaction_returns_400(b, client, user_pk): def test_transactions_get_list_good(client): from functools import partial + def gtf(conn, **args): return [type('', (), {'to_dict': partial(lambda a: a, arg)}) for arg in sorted(args.items())] @@ -205,6 +206,8 @@ def test_transactions_get_list_good(client): def test_transactions_get_list_bad(client): + def should_not_be_called(): + assert False with patch('bigchaindb.core.Bigchain.get_transactions_filtered', lambda *_, **__: should_not_be_called()): # Test asset id validated