From af23ff5b65a008752a832f824d65dcf7baeb18e2 Mon Sep 17 00:00:00 2001 From: Scott Sadler Date: Tue, 24 Jan 2017 12:08:55 +0100 Subject: [PATCH] clean up use of double quotes, rename UNSPENTS_ENDPOINT, clarify test --- tests/db/test_bigchain_api.py | 4 ++-- tests/web/test_outputs.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/db/test_bigchain_api.py b/tests/db/test_bigchain_api.py index 78c14a28..bd0508de 100644 --- a/tests/db/test_bigchain_api.py +++ b/tests/db/test_bigchain_api.py @@ -1163,8 +1163,8 @@ def test_get_owned_ids_calls_get_outputs_filtered(): from bigchaindb.core import Bigchain with patch('bigchaindb.core.Bigchain.get_outputs_filtered') as gof: b = Bigchain() - res = b.get_owned_ids("abc") - gof.assert_called_once_with("abc", include_spent=False) + res = b.get_owned_ids('abc') + gof.assert_called_once_with('abc', include_spent=False) assert res == gof() diff --git a/tests/web/test_outputs.py b/tests/web/test_outputs.py index 8fb418ea..fd17d46d 100644 --- a/tests/web/test_outputs.py +++ b/tests/web/test_outputs.py @@ -3,40 +3,40 @@ from unittest.mock import MagicMock, patch pytestmark = [pytest.mark.bdb, pytest.mark.usefixtures('inputs')] -UNSPENTS_ENDPOINT = '/api/v1/outputs/' +OUTPUTS_ENDPOINT = '/api/v1/outputs/' def test_get_outputs_endpoint(client, user_pk): m = MagicMock() - m.to_uri.side_effect = lambda s: s + m.to_uri.side_effect = lambda s: 'a%sb' % s with patch('bigchaindb.core.Bigchain.get_outputs_filtered') as gof: gof.return_value = [m, m] - res = client.get(UNSPENTS_ENDPOINT + '?public_key={}'.format(user_pk)) - assert res.json == ["..", ".."] + res = client.get(OUTPUTS_ENDPOINT + '?public_key={}'.format(user_pk)) + assert res.json == ['a..b', 'a..b'] assert res.status_code == 200 gof.assert_called_once_with(user_pk, True) def test_get_outputs_endpoint_unspent(client, user_pk): m = MagicMock() - m.to_uri.side_effect = lambda s: s + m.to_uri.side_effect = lambda s: 'a%sb' % s with patch('bigchaindb.core.Bigchain.get_outputs_filtered') as gof: gof.return_value = [m] params = '?unspent=true&public_key={}'.format(user_pk) - res = client.get(UNSPENTS_ENDPOINT + params) - assert res.json == [".."] + res = client.get(OUTPUTS_ENDPOINT + params) + assert res.json == ['a..b'] assert res.status_code == 200 gof.assert_called_once_with(user_pk, False) def test_get_outputs_endpoint_without_public_key(client): - res = client.get(UNSPENTS_ENDPOINT) + res = client.get(OUTPUTS_ENDPOINT) assert res.status_code == 400 def test_get_outputs_endpoint_with_invalid_public_key(client): expected = {'message': {'public_key': 'Invalid base58 ed25519 key'}} - res = client.get(UNSPENTS_ENDPOINT + '?public_key=abc') + res = client.get(OUTPUTS_ENDPOINT + '?public_key=abc') assert expected == res.json assert res.status_code == 400 @@ -44,6 +44,6 @@ def test_get_outputs_endpoint_with_invalid_public_key(client): def test_get_outputs_endpoint_with_invalid_unspent(client, user_pk): expected = {'message': {'unspent': 'Boolean value must be "true" or "false" (lowercase)'}} params = '?unspent=tru&public_key={}'.format(user_pk) - res = client.get(UNSPENTS_ENDPOINT + params) + res = client.get(OUTPUTS_ENDPOINT + params) assert expected == res.json assert res.status_code == 400