mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: several tests are skipped
Solution: activate or remove tests
This commit is contained in:
parent
ab41b463d8
commit
2bfcd76d17
@ -6,6 +6,8 @@ import pytest
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.tendermint
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def reset_bigchaindb_config(monkeypatch):
|
def reset_bigchaindb_config(monkeypatch):
|
||||||
|
|||||||
@ -18,6 +18,7 @@ pytestmark = pytest.mark.tendermint
|
|||||||
|
|
||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
def test_asset_is_separated_from_transaciton(b):
|
def test_asset_is_separated_from_transaciton(b):
|
||||||
|
import copy
|
||||||
from bigchaindb.models import Transaction
|
from bigchaindb.models import Transaction
|
||||||
from bigchaindb.common.crypto import generate_key_pair
|
from bigchaindb.common.crypto import generate_key_pair
|
||||||
|
|
||||||
@ -39,10 +40,12 @@ def test_asset_is_separated_from_transaciton(b):
|
|||||||
asset=asset)\
|
asset=asset)\
|
||||||
.sign([alice.private_key])
|
.sign([alice.private_key])
|
||||||
|
|
||||||
b.store_transaction(tx)
|
tx_dict = copy.deepcopy(tx.to_dict())
|
||||||
|
|
||||||
|
b.store_bulk_transactions([tx])
|
||||||
assert 'asset' not in backend.query.get_transaction(b.connection, tx.id)
|
assert 'asset' not in backend.query.get_transaction(b.connection, tx.id)
|
||||||
assert backend.query.get_asset(b.connection, tx.id)['data'] == asset
|
assert backend.query.get_asset(b.connection, tx.id)['data'] == asset
|
||||||
assert b.get_transaction(tx.id) == tx
|
assert b.get_transaction(tx.id).to_dict() == tx_dict
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
@ -176,54 +179,6 @@ def test_update_utxoset(tb, signed_create_tx, signed_transfer_tx, db_context):
|
|||||||
assert utxo['output_index'] == 0
|
assert utxo['output_index'] == 0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.bdb
|
|
||||||
def test_store_transaction(mocker, tb, signed_create_tx,
|
|
||||||
signed_transfer_tx, db_context):
|
|
||||||
mocked_store_asset = mocker.patch('bigchaindb.backend.query.store_asset')
|
|
||||||
mocked_store_metadata = mocker.patch(
|
|
||||||
'bigchaindb.backend.query.store_metadatas')
|
|
||||||
mocked_store_transaction = mocker.patch(
|
|
||||||
'bigchaindb.backend.query.store_transaction')
|
|
||||||
tb.store_transaction(signed_create_tx)
|
|
||||||
# mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
|
||||||
# utxoset = mongo_client[db_context.name]['utxos']
|
|
||||||
# assert utxoset.count() == 1
|
|
||||||
# utxo = utxoset.find_one()
|
|
||||||
# assert utxo['transaction_id'] == signed_create_tx.id
|
|
||||||
# assert utxo['output_index'] == 0
|
|
||||||
mocked_store_asset.assert_called_once_with(
|
|
||||||
tb.connection,
|
|
||||||
{'id': signed_create_tx.id, 'data': signed_create_tx.asset['data']},
|
|
||||||
)
|
|
||||||
mocked_store_metadata.assert_called_once_with(
|
|
||||||
tb.connection,
|
|
||||||
[{'id': signed_create_tx.id, 'metadata': signed_create_tx.metadata}],
|
|
||||||
)
|
|
||||||
mocked_store_transaction.assert_called_once_with(
|
|
||||||
tb.connection,
|
|
||||||
{k: v for k, v in signed_create_tx.to_dict().items()
|
|
||||||
if k not in ('asset', 'metadata')},
|
|
||||||
)
|
|
||||||
mocked_store_asset.reset_mock()
|
|
||||||
mocked_store_metadata.reset_mock()
|
|
||||||
mocked_store_transaction.reset_mock()
|
|
||||||
tb.store_transaction(signed_transfer_tx)
|
|
||||||
# assert utxoset.count() == 1
|
|
||||||
# utxo = utxoset.find_one()
|
|
||||||
# assert utxo['transaction_id'] == signed_transfer_tx.id
|
|
||||||
# assert utxo['output_index'] == 0
|
|
||||||
assert not mocked_store_asset.called
|
|
||||||
mocked_store_metadata.asser_called_once_with(
|
|
||||||
tb.connection,
|
|
||||||
{'id': signed_transfer_tx.id, 'metadata': signed_transfer_tx.metadata},
|
|
||||||
)
|
|
||||||
mocked_store_transaction.assert_called_once_with(
|
|
||||||
tb.connection,
|
|
||||||
{k: v for k, v in signed_transfer_tx.to_dict().items()
|
|
||||||
if k != 'metadata'},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
def test_store_bulk_transaction(mocker, tb, signed_create_tx,
|
def test_store_bulk_transaction(mocker, tb, signed_create_tx,
|
||||||
signed_transfer_tx, db_context):
|
signed_transfer_tx, db_context):
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import pytest
|
|||||||
pytestmark = pytest.mark.tendermint
|
pytestmark = pytest.mark.tendermint
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(reason='will be fixed in another PR')
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def config(request, monkeypatch):
|
def config(request, monkeypatch):
|
||||||
backend = request.config.getoption('--database-backend')
|
backend = request.config.getoption('--database-backend')
|
||||||
|
|||||||
@ -33,7 +33,7 @@ def test_get_assets_tendermint(client, tb, alice):
|
|||||||
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)],
|
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)],
|
||||||
asset=asset).sign([alice.private_key])
|
asset=asset).sign([alice.private_key])
|
||||||
|
|
||||||
tb.store_transaction(tx)
|
tb.store_bulk_transactions([tx])
|
||||||
|
|
||||||
# test that asset is returned
|
# test that asset is returned
|
||||||
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
||||||
@ -60,8 +60,8 @@ def test_get_assets_limit_tendermint(client, tb, alice):
|
|||||||
tx2 = Transaction.create([alice.public_key], [([alice.public_key], 1)],
|
tx2 = Transaction.create([alice.public_key], [([alice.public_key], 1)],
|
||||||
asset=asset2).sign([alice.private_key])
|
asset=asset2).sign([alice.private_key])
|
||||||
|
|
||||||
b.store_transaction(tx1)
|
b.store_bulk_transactions([tx1])
|
||||||
b.store_transaction(tx2)
|
b.store_bulk_transactions([tx2])
|
||||||
|
|
||||||
# test that both assets are returned without limit
|
# test that both assets are returned without limit
|
||||||
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
||||||
|
|||||||
@ -11,10 +11,12 @@ pytestmark = pytest.mark.tendermint
|
|||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
@pytest.mark.usefixtures('inputs')
|
@pytest.mark.usefixtures('inputs')
|
||||||
def test_get_block_endpoint(tb, client, alice):
|
def test_get_block_endpoint(tb, client, alice):
|
||||||
|
import copy
|
||||||
b = tb
|
b = tb
|
||||||
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)], asset={'cycle': 'hero'})
|
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)], asset={'cycle': 'hero'})
|
||||||
tx = tx.sign([alice.private_key])
|
tx = tx.sign([alice.private_key])
|
||||||
b.store_transaction(tx)
|
tx_dict = copy.deepcopy(tx.to_dict())
|
||||||
|
b.store_bulk_transactions([tx])
|
||||||
|
|
||||||
block = Block(app_hash='random_utxo',
|
block = Block(app_hash='random_utxo',
|
||||||
height=31,
|
height=31,
|
||||||
@ -22,7 +24,7 @@ def test_get_block_endpoint(tb, client, alice):
|
|||||||
b.store_block(block._asdict())
|
b.store_block(block._asdict())
|
||||||
|
|
||||||
res = client.get(BLOCKS_ENDPOINT + str(block.height))
|
res = client.get(BLOCKS_ENDPOINT + str(block.height))
|
||||||
expected_response = {'height': block.height, 'transactions': [tx.to_dict()]}
|
expected_response = {'height': block.height, 'transactions': [tx_dict]}
|
||||||
assert res.json == expected_response
|
assert res.json == expected_response
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
|
|
||||||
@ -42,7 +44,7 @@ def test_get_block_containing_transaction(tb, client, alice):
|
|||||||
b = tb
|
b = tb
|
||||||
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)], asset={'cycle': 'hero'})
|
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)], asset={'cycle': 'hero'})
|
||||||
tx = tx.sign([alice.private_key])
|
tx = tx.sign([alice.private_key])
|
||||||
b.store_transaction(tx)
|
b.store_bulk_transactions([tx])
|
||||||
|
|
||||||
block = Block(app_hash='random_utxo',
|
block = Block(app_hash='random_utxo',
|
||||||
height=13,
|
height=13,
|
||||||
|
|||||||
@ -35,7 +35,7 @@ def test_get_metadata_tendermint(client, tb, alice):
|
|||||||
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)], metadata=metadata,
|
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)], metadata=metadata,
|
||||||
asset=asset).sign([alice.private_key])
|
asset=asset).sign([alice.private_key])
|
||||||
|
|
||||||
b.store_transaction(tx)
|
b.store_bulk_transactions([tx])
|
||||||
|
|
||||||
# test that metadata is returned
|
# test that metadata is returned
|
||||||
res = client.get(METADATA_ENDPOINT + '?search=my_meta')
|
res = client.get(METADATA_ENDPOINT + '?search=my_meta')
|
||||||
@ -59,13 +59,13 @@ def test_get_metadata_limit_tendermint(client, tb, alice):
|
|||||||
meta1 = {'key': 'meta 1'}
|
meta1 = {'key': 'meta 1'}
|
||||||
tx1 = Transaction.create([alice.public_key], [([alice.public_key], 1)], metadata=meta1,
|
tx1 = Transaction.create([alice.public_key], [([alice.public_key], 1)], metadata=meta1,
|
||||||
asset=asset1).sign([alice.private_key])
|
asset=asset1).sign([alice.private_key])
|
||||||
b.store_transaction(tx1)
|
b.store_bulk_transactions([tx1])
|
||||||
|
|
||||||
asset2 = {'msg': 'abc 2'}
|
asset2 = {'msg': 'abc 2'}
|
||||||
meta2 = {'key': 'meta 2'}
|
meta2 = {'key': 'meta 2'}
|
||||||
tx2 = Transaction.create([alice.public_key], [([alice.public_key], 1)], metadata=meta2,
|
tx2 = Transaction.create([alice.public_key], [([alice.public_key], 1)], metadata=meta2,
|
||||||
asset=asset2).sign([alice.private_key])
|
asset=asset2).sign([alice.private_key])
|
||||||
b.store_transaction(tx2)
|
b.store_bulk_transactions([tx2])
|
||||||
|
|
||||||
# test that both assets are returned without limit
|
# test that both assets are returned without limit
|
||||||
res = client.get(METADATA_ENDPOINT + '?search=meta')
|
res = client.get(METADATA_ENDPOINT + '?search=meta')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user