mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-06-30 13:42:00 +02:00
remove rethinkdb calls (#953)
* remove rethinkdb calls from db/conftest.py
This commit is contained in:
parent
588d6eb177
commit
d8256d50f2
|
@ -8,12 +8,6 @@ def restore_config(request, node_config):
|
||||||
config_utils.set_config(node_config)
|
config_utils.set_config(node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module', autouse=True)
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
def setup_database(request, node_config):
|
def setup_database(request, node_config):
|
||||||
conftest.setup_database(request, node_config)
|
conftest.setup_database(request, node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function', autouse=True)
|
|
||||||
def cleanup_tables(request, node_config):
|
|
||||||
conftest.cleanup_tables(request, node_config)
|
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,11 @@ Tasks:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import rethinkdb as r
|
|
||||||
|
|
||||||
from bigchaindb import Bigchain
|
from bigchaindb import Bigchain
|
||||||
from bigchaindb.backend import connect, schema
|
from bigchaindb.backend import connect, schema
|
||||||
from bigchaindb.common import crypto
|
from bigchaindb.common import crypto
|
||||||
from bigchaindb.common.exceptions import DatabaseAlreadyExists
|
from bigchaindb.common.exceptions import DatabaseDoesNotExist
|
||||||
|
|
||||||
|
|
||||||
USER2_SK, USER2_PK = crypto.generate_key_pair()
|
USER2_SK, USER2_PK = crypto.generate_key_pair()
|
||||||
|
@ -24,52 +23,34 @@ def restore_config(request, node_config):
|
||||||
config_utils.set_config(node_config)
|
config_utils.set_config(node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module', autouse=True)
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
def setup_database(request, node_config):
|
def setup_database(request, node_config):
|
||||||
print('Initializing test db')
|
print('Initializing test db')
|
||||||
db_name = node_config['database']['name']
|
db_name = node_config['database']['name']
|
||||||
conn = connect()
|
conn = connect()
|
||||||
|
|
||||||
if conn.run(r.db_list().contains(db_name)):
|
|
||||||
conn.run(r.db_drop(db_name))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
schema.init_database()
|
schema.drop_database(conn, db_name)
|
||||||
except DatabaseAlreadyExists:
|
except DatabaseDoesNotExist:
|
||||||
print('Database already exists.')
|
pass
|
||||||
|
|
||||||
|
schema.init_database(conn)
|
||||||
|
|
||||||
print('Finishing init database')
|
print('Finishing init database')
|
||||||
|
|
||||||
def fin():
|
def fin():
|
||||||
|
conn = connect()
|
||||||
print('Deleting `{}` database'.format(db_name))
|
print('Deleting `{}` database'.format(db_name))
|
||||||
conn = connect()
|
|
||||||
try:
|
try:
|
||||||
conn.run(r.db_drop(db_name))
|
schema.drop_database(conn, db_name)
|
||||||
except r.ReqlOpFailedError as e:
|
except DatabaseDoesNotExist:
|
||||||
if e.message != 'Database `{}` does not exist.'.format(db_name):
|
pass
|
||||||
raise
|
|
||||||
print('Finished deleting `{}`'.format(db_name))
|
print('Finished deleting `{}`'.format(db_name))
|
||||||
|
|
||||||
request.addfinalizer(fin)
|
request.addfinalizer(fin)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function', autouse=True)
|
|
||||||
def cleanup_tables(request, node_config):
|
|
||||||
db_name = node_config['database']['name']
|
|
||||||
|
|
||||||
def fin():
|
|
||||||
conn = connect()
|
|
||||||
try:
|
|
||||||
conn.run(r.db(db_name).table('bigchain').delete())
|
|
||||||
conn.run(r.db(db_name).table('backlog').delete())
|
|
||||||
conn.run(r.db(db_name).table('votes').delete())
|
|
||||||
except r.ReqlOpFailedError as e:
|
|
||||||
if e.message != 'Database `{}` does not exist.'.format(db_name):
|
|
||||||
raise
|
|
||||||
|
|
||||||
request.addfinalizer(fin)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def inputs(user_pk):
|
def inputs(user_pk):
|
||||||
from bigchaindb.models import Transaction
|
from bigchaindb.models import Transaction
|
||||||
|
|
|
@ -11,16 +11,11 @@ def restore_config(request, node_config):
|
||||||
config_utils.set_config(node_config)
|
config_utils.set_config(node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module', autouse=True)
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
def setup_database(request, node_config):
|
def setup_database(request, node_config):
|
||||||
conftest.setup_database(request, node_config)
|
conftest.setup_database(request, node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function', autouse=True)
|
|
||||||
def cleanup_tables(request, node_config):
|
|
||||||
conftest.cleanup_tables(request, node_config)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def processes(b):
|
def processes(b):
|
||||||
b.create_genesis_block()
|
b.create_genesis_block()
|
||||||
|
|
|
@ -8,11 +8,6 @@ def restore_config(request, node_config):
|
||||||
config_utils.set_config(node_config)
|
config_utils.set_config(node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module', autouse=True)
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
def setup_database(request, node_config):
|
def setup_database(request, node_config):
|
||||||
conftest.setup_database(request, node_config)
|
conftest.setup_database(request, node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function', autouse=True)
|
|
||||||
def cleanup_tables(request, node_config):
|
|
||||||
conftest.cleanup_tables(request, node_config)
|
|
||||||
|
|
|
@ -8,16 +8,11 @@ def restore_config(request, node_config):
|
||||||
config_utils.set_config(node_config)
|
config_utils.set_config(node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module', autouse=True)
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
def setup_database(request, node_config):
|
def setup_database(request, node_config):
|
||||||
conftest.setup_database(request, node_config)
|
conftest.setup_database(request, node_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function', autouse=True)
|
|
||||||
def cleanup_tables(request, node_config):
|
|
||||||
conftest.cleanup_tables(request, node_config)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def app(request, node_config):
|
def app(request, node_config):
|
||||||
# XXX: For whatever reason this fixture runs before `restore_config`,
|
# XXX: For whatever reason this fixture runs before `restore_config`,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user