mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-06-28 00:27:45 +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)
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
@pytest.fixture(scope='function', autouse=True)
|
||||
def 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 rethinkdb as r
|
||||
|
||||
from bigchaindb import Bigchain
|
||||
from bigchaindb.backend import connect, schema
|
||||
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()
|
||||
|
@ -24,52 +23,34 @@ def restore_config(request, 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):
|
||||
print('Initializing test db')
|
||||
db_name = node_config['database']['name']
|
||||
conn = connect()
|
||||
|
||||
if conn.run(r.db_list().contains(db_name)):
|
||||
conn.run(r.db_drop(db_name))
|
||||
|
||||
try:
|
||||
schema.init_database()
|
||||
except DatabaseAlreadyExists:
|
||||
print('Database already exists.')
|
||||
schema.drop_database(conn, db_name)
|
||||
except DatabaseDoesNotExist:
|
||||
pass
|
||||
|
||||
schema.init_database(conn)
|
||||
|
||||
print('Finishing init database')
|
||||
|
||||
def fin():
|
||||
conn = connect()
|
||||
print('Deleting `{}` database'.format(db_name))
|
||||
conn = connect()
|
||||
try:
|
||||
conn.run(r.db_drop(db_name))
|
||||
except r.ReqlOpFailedError as e:
|
||||
if e.message != 'Database `{}` does not exist.'.format(db_name):
|
||||
raise
|
||||
schema.drop_database(conn, db_name)
|
||||
except DatabaseDoesNotExist:
|
||||
pass
|
||||
|
||||
print('Finished deleting `{}`'.format(db_name))
|
||||
|
||||
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
|
||||
def inputs(user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
|
|
@ -11,16 +11,11 @@ def restore_config(request, 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):
|
||||
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
|
||||
def processes(b):
|
||||
b.create_genesis_block()
|
||||
|
|
|
@ -8,11 +8,6 @@ def restore_config(request, 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):
|
||||
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)
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
@pytest.fixture(scope='function', autouse=True)
|
||||
def 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
|
||||
def app(request, node_config):
|
||||
# XXX: For whatever reason this fixture runs before `restore_config`,
|
||||
|
|
Loading…
Reference in New Issue
Block a user