diff --git a/tests/backend/localmongodb/test_queries.py b/tests/backend/localmongodb/test_queries.py index 941c1a27..1a22ba2b 100644 --- a/tests/backend/localmongodb/test_queries.py +++ b/tests/backend/localmongodb/test_queries.py @@ -3,7 +3,7 @@ from copy import deepcopy import pytest import pymongo -pytestmark = pytest.mark.tendermint +pytestmark = [pytest.mark.tendermint, pytest.mark.localmongodb] @pytest.mark.bdb @@ -75,7 +75,6 @@ def test_get_assets(): @pytest.mark.bdb -@pytest.mark.tendermint def test_text_search(): from ..mongodb.test_queries import test_text_search diff --git a/tests/conftest.py b/tests/conftest.py index e3881b99..aaaa5077 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,6 +25,13 @@ USER_PRIVATE_KEY = '8eJ8q9ZQpReWyQT5aFCiwtZ5wDZC4eDnCen88p3tQ6ie' USER_PUBLIC_KEY = 'JEAkEJqLbbgDRAtMm8YAjGp759Aq2qTn9eaEHUj2XePE' +def pytest_runtest_setup(item): + if isinstance(item, item.Function): + backend = item.session.config.getoption('--database-backend') + if (item.get_marker('localmongodb') and backend != 'localmongodb'): + pytest.skip('Skip tendermint specific tests if not using localmongodb') + + def pytest_addoption(parser): from bigchaindb.backend.connection import BACKENDS diff --git a/tests/web/test_assets.py b/tests/web/test_assets.py index 3b22fefd..71e93f9f 100644 --- a/tests/web/test_assets.py +++ b/tests/web/test_assets.py @@ -87,58 +87,56 @@ def test_get_assets_limit(client, b): @pytest.mark.bdb @pytest.mark.tendermint -def test_get_assets_tmint(client, tb): +@pytest.mark.localmongodb +def test_get_assets_tendermint(client, tb): from bigchaindb.models import Transaction - from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection - if isinstance(tb.connection, LocalMongoDBConnection): - # test returns empty list when no assets are found - res = client.get(ASSETS_ENDPOINT + '?search=abc') - assert res.json == [] - assert res.status_code == 200 + # 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([tb.me], [([tb.me], 1)], - asset=asset).sign([tb.me_private]) + # create asset + asset = {'msg': 'abc'} + tx = Transaction.create([tb.me], [([tb.me], 1)], + asset=asset).sign([tb.me_private]) - tb.store_transaction(tx) + 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 - } + # 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 -def test_get_assets_limit_tmint(client, tb): +@pytest.mark.localmongodb +def test_get_assets_limit_tendermint(client, tb): from bigchaindb.models import Transaction - from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection b = tb - if isinstance(b.connection, LocalMongoDBConnection): - # create two assets - asset1 = {'msg': 'abc 1'} - asset2 = {'msg': 'abc 2'} - tx1 = Transaction.create([b.me], [([b.me], 1)], - asset=asset1).sign([b.me_private]) - tx2 = Transaction.create([b.me], [([b.me], 1)], - asset=asset2).sign([b.me_private]) + # create two assets + asset1 = {'msg': 'abc 1'} + asset2 = {'msg': 'abc 2'} + tx1 = Transaction.create([b.me], [([b.me], 1)], + asset=asset1).sign([b.me_private]) + tx2 = Transaction.create([b.me], [([b.me], 1)], + asset=asset2).sign([b.me_private]) - b.store_transaction(tx1) - b.store_transaction(tx2) + 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 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 + # 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