mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Added localmongodb marker
This commit is contained in:
parent
6c3f176122
commit
fcfe577813
@ -3,7 +3,7 @@ from copy import deepcopy
|
|||||||
import pytest
|
import pytest
|
||||||
import pymongo
|
import pymongo
|
||||||
|
|
||||||
pytestmark = pytest.mark.tendermint
|
pytestmark = [pytest.mark.tendermint, pytest.mark.localmongodb]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
@ -75,7 +75,6 @@ def test_get_assets():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
@pytest.mark.tendermint
|
|
||||||
def test_text_search():
|
def test_text_search():
|
||||||
from ..mongodb.test_queries import test_text_search
|
from ..mongodb.test_queries import test_text_search
|
||||||
|
|
||||||
|
@ -25,6 +25,13 @@ USER_PRIVATE_KEY = '8eJ8q9ZQpReWyQT5aFCiwtZ5wDZC4eDnCen88p3tQ6ie'
|
|||||||
USER_PUBLIC_KEY = 'JEAkEJqLbbgDRAtMm8YAjGp759Aq2qTn9eaEHUj2XePE'
|
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):
|
def pytest_addoption(parser):
|
||||||
from bigchaindb.backend.connection import BACKENDS
|
from bigchaindb.backend.connection import BACKENDS
|
||||||
|
|
||||||
|
@ -87,58 +87,56 @@ def test_get_assets_limit(client, b):
|
|||||||
|
|
||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
@pytest.mark.tendermint
|
@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.models import Transaction
|
||||||
from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection
|
|
||||||
|
|
||||||
if isinstance(tb.connection, LocalMongoDBConnection):
|
# test returns empty list when no assets are found
|
||||||
# test returns empty list when no assets are found
|
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
||||||
res = client.get(ASSETS_ENDPOINT + '?search=abc')
|
assert res.json == []
|
||||||
assert res.json == []
|
assert res.status_code == 200
|
||||||
assert res.status_code == 200
|
|
||||||
|
|
||||||
# create asset
|
# create asset
|
||||||
asset = {'msg': 'abc'}
|
asset = {'msg': 'abc'}
|
||||||
tx = Transaction.create([tb.me], [([tb.me], 1)],
|
tx = Transaction.create([tb.me], [([tb.me], 1)],
|
||||||
asset=asset).sign([tb.me_private])
|
asset=asset).sign([tb.me_private])
|
||||||
|
|
||||||
tb.store_transaction(tx)
|
tb.store_transaction(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')
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
assert len(res.json) == 1
|
assert len(res.json) == 1
|
||||||
assert res.json[0] == {
|
assert res.json[0] == {
|
||||||
'data': {'msg': 'abc'},
|
'data': {'msg': 'abc'},
|
||||||
'id': tx.id
|
'id': tx.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
@pytest.mark.tendermint
|
@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.models import Transaction
|
||||||
from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection
|
|
||||||
|
|
||||||
b = tb
|
b = tb
|
||||||
if isinstance(b.connection, LocalMongoDBConnection):
|
# create two assets
|
||||||
# create two assets
|
asset1 = {'msg': 'abc 1'}
|
||||||
asset1 = {'msg': 'abc 1'}
|
asset2 = {'msg': 'abc 2'}
|
||||||
asset2 = {'msg': 'abc 2'}
|
tx1 = Transaction.create([b.me], [([b.me], 1)],
|
||||||
tx1 = Transaction.create([b.me], [([b.me], 1)],
|
asset=asset1).sign([b.me_private])
|
||||||
asset=asset1).sign([b.me_private])
|
tx2 = Transaction.create([b.me], [([b.me], 1)],
|
||||||
tx2 = Transaction.create([b.me], [([b.me], 1)],
|
asset=asset2).sign([b.me_private])
|
||||||
asset=asset2).sign([b.me_private])
|
|
||||||
|
|
||||||
b.store_transaction(tx1)
|
b.store_transaction(tx1)
|
||||||
b.store_transaction(tx2)
|
b.store_transaction(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')
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
assert len(res.json) == 2
|
assert len(res.json) == 2
|
||||||
|
|
||||||
# test that only one asset is returned when using limit=1
|
# test that only one asset is returned when using limit=1
|
||||||
res = client.get(ASSETS_ENDPOINT + '?search=abc&limit=1')
|
res = client.get(ASSETS_ENDPOINT + '?search=abc&limit=1')
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
assert len(res.json) == 1
|
assert len(res.json) == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user