small fix to test

This commit is contained in:
Rodolphe Marques 2017-01-10 15:31:16 +01:00
parent f4bbf27815
commit aa6d4fdcc8
2 changed files with 6 additions and 15 deletions

View File

@ -94,24 +94,15 @@ def test_create_secondary_indexes():
assert sorted(indexes) == ['_id_', 'block_and_voter']
# The database is set up with a session scope.
# If we run this test we will remove secondary indexes that are nedeed for
# the rest of the tests
@pytest.mark.skipif(reason='This will remove the secondary indexes needed'
' for the rest of the tests')
def test_drop():
def test_drop(dummy_db):
import bigchaindb
from bigchaindb import backend
from bigchaindb.backend import schema
conn = backend.connect()
dbname = bigchaindb.config['database']['name']
# The db is set up by fixtures
assert dbname in conn.conn.database_names()
schema.drop_database(conn, dbname)
assert dbname not in conn.conn.database_names()
assert dummy_db in conn.conn.database_names()
schema.drop_database(conn, dummy_db)
assert dummy_db not in conn.conn.database_names()
def test_get_replica_set_name_not_enabled():

View File

@ -322,10 +322,10 @@ def dummy_db(request):
if xdist_suffix:
dbname = '{}_{}'.format(dbname, xdist_suffix)
try:
schema.create_database(conn, dbname)
schema.init_database(conn, dbname)
except DatabaseAlreadyExists:
schema.drop_database(conn, dbname)
schema.create_database(conn, dbname)
schema.init_database(conn, dbname)
yield dbname
try:
schema.drop_database(conn, dbname)