mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00

* Problem: BigchainDB config has stale/deprecated parameters - Remove `keyring` and `keypair` from config - Update tests - Add `tendermint` config * Fix flake8 * Update some naming conventions and redundant changes * Remove redundant routine `fast_query` * Remove deprecated parameters and descriptions * remove some more unwanted code * Problem: Two flake8 errors made Travis fail Solution: Fix the two flake8 errors * Address comments - Remove reference of nodes_except_me and me_private and me as attributes of BigchainDB instances - Update and re-add test(s) - Do not introduce `tendermint` in configuration instead handle that in a separate PR along with docs * Address comments - Remove tests that are already covered with 2.0 - Remove tests that are no longer relevant - Add TODO for more cleanup * Remove tendermint config from configure command
75 lines
2.2 KiB
Python
75 lines
2.2 KiB
Python
import pytest
|
|
|
|
ASSETS_ENDPOINT = '/api/v1/assets/'
|
|
|
|
|
|
@pytest.mark.tendermint
|
|
def test_get_assets_with_empty_text_search(client):
|
|
res = client.get(ASSETS_ENDPOINT + '?search=')
|
|
assert res.json == {'status': 400,
|
|
'message': 'text_search cannot be empty'}
|
|
assert res.status_code == 400
|
|
|
|
|
|
@pytest.mark.tendermint
|
|
def test_get_assets_with_missing_text_search(client):
|
|
res = client.get(ASSETS_ENDPOINT)
|
|
assert res.status_code == 400
|
|
|
|
|
|
@pytest.mark.bdb
|
|
@pytest.mark.tendermint
|
|
@pytest.mark.localmongodb
|
|
def test_get_assets_tendermint(client, tb, alice):
|
|
from bigchaindb.models import Transaction
|
|
|
|
# test returns empty list when no assets are found
|
|
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
|
assert res.json == []
|
|
assert res.status_code == 200
|
|
|
|
# create asset
|
|
asset = {'msg': 'abc'}
|
|
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)],
|
|
asset=asset).sign([alice.private_key])
|
|
|
|
tb.store_transaction(tx)
|
|
|
|
# test that asset is returned
|
|
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
|
assert res.status_code == 200
|
|
assert len(res.json) == 1
|
|
assert res.json[0] == {
|
|
'data': {'msg': 'abc'},
|
|
'id': tx.id
|
|
}
|
|
|
|
|
|
@pytest.mark.bdb
|
|
@pytest.mark.tendermint
|
|
@pytest.mark.localmongodb
|
|
def test_get_assets_limit_tendermint(client, tb, alice):
|
|
from bigchaindb.models import Transaction
|
|
|
|
b = tb
|
|
# create two assets
|
|
asset1 = {'msg': 'abc 1'}
|
|
asset2 = {'msg': 'abc 2'}
|
|
tx1 = Transaction.create([alice.public_key], [([alice.public_key], 1)],
|
|
asset=asset1).sign([alice.private_key])
|
|
tx2 = Transaction.create([alice.public_key], [([alice.public_key], 1)],
|
|
asset=asset2).sign([alice.private_key])
|
|
|
|
b.store_transaction(tx1)
|
|
b.store_transaction(tx2)
|
|
|
|
# test that both assets are returned without limit
|
|
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
|
assert res.status_code == 200
|
|
assert len(res.json) == 2
|
|
|
|
# test that only one asset is returned when using limit=1
|
|
res = client.get(ASSETS_ENDPOINT + '?search=abc&limit=1')
|
|
assert res.status_code == 200
|
|
assert len(res.json) == 1
|