From ccd8e748682ea95cbed20a08f4246ddc1d73c67d Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Tue, 6 Dec 2016 15:06:01 +0100 Subject: [PATCH] Fix initialization-related tests for rethinkdb schema --- tests/db/rethinkdb/test_schema.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/db/rethinkdb/test_schema.py b/tests/db/rethinkdb/test_schema.py index c99612f7..9c489be6 100644 --- a/tests/db/rethinkdb/test_schema.py +++ b/tests/db/rethinkdb/test_schema.py @@ -15,13 +15,14 @@ def setup_database(request, node_config): def test_init_creates_db_tables_and_indexes(): + from bigchaindb.backend.schema import init_database conn = backend.connect() dbname = bigchaindb.config['database']['name'] # The db is set up by fixtures so we need to remove it conn.run(r.db_drop(dbname)) - schema.create_database(conn, dbname) + init_database() assert conn.run(r.db_list().contains(dbname)) is True @@ -34,6 +35,20 @@ def test_init_creates_db_tables_and_indexes(): 'assignee__transaction_timestamp')) is True +def test_init_database_fails_if_db_exists(): + from bigchaindb.backend.schema import init_database + from bigchaindb.common import exceptions + + conn = backend.connect() + dbname = bigchaindb.config['database']['name'] + + # The db is set up by fixtures + assert conn.run(r.db_list().contains(dbname)) is True + + with pytest.raises(exceptions.DatabaseAlreadyExists): + init_database() + + def test_create_database(): conn = backend.connect() dbname = bigchaindb.config['database']['name'] @@ -91,19 +106,6 @@ def test_create_bigchain_secondary_index(): 'block_and_voter')) is True -def test_init_database_fails_if_db_exists(): - from bigchaindb.common import exceptions - - conn = backend.connect() - dbname = bigchaindb.config['database']['name'] - - # The db is set up by fixtures - assert conn.run(r.db_list().contains(dbname)) is True - - with pytest.raises(exceptions.DatabaseAlreadyExists): - schema.init_database() - - def test_drop(): conn = backend.connect() dbname = bigchaindb.config['database']['name']