From 941b47d1acb9ec64e79dc15dad872fcccb33d51e Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Mon, 5 Dec 2016 20:13:12 +0100 Subject: [PATCH] Fix misc tests affected by changes related to database abstraction --- tests/pipelines/test_utils.py | 2 +- tests/test_core.py | 4 ++-- tests/test_run_query_util.py | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/pipelines/test_utils.py b/tests/pipelines/test_utils.py index 66f1bdd9..e0e8dccc 100644 --- a/tests/pipelines/test_utils.py +++ b/tests/pipelines/test_utils.py @@ -1,7 +1,7 @@ from unittest.mock import patch from multipipes import Pipe -from bigchaindb.db.utils import Connection +from bigchaindb.backend.connection import Connection from bigchaindb.pipelines.utils import ChangeFeed diff --git a/tests/test_core.py b/tests/test_core.py index 55d73e77..d78a08bf 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -62,12 +62,12 @@ def test_bigchain_class_initialization_with_parameters(config): def test_get_blocks_status_containing_tx(monkeypatch): - from bigchaindb.db.backends.rethinkdb import RethinkDBBackend + from bigchaindb.backend import query as backend_query from bigchaindb.core import Bigchain blocks = [ {'id': 1}, {'id': 2} ] - monkeypatch.setattr(RethinkDBBackend, 'get_blocks_status_from_transaction', lambda x: blocks) + monkeypatch.setattr(backend_query, 'get_blocks_status_from_transaction', lambda x: blocks) monkeypatch.setattr(Bigchain, 'block_election_status', lambda x, y, z: Bigchain.BLOCK_VALID) bigchain = Bigchain(public_key='pubkey', private_key='privkey') with pytest.raises(Exception): diff --git a/tests/test_run_query_util.py b/tests/test_run_query_util.py index f81bd232..1aeea11e 100644 --- a/tests/test_run_query_util.py +++ b/tests/test_run_query_util.py @@ -3,11 +3,11 @@ import pytest import rethinkdb as r -from bigchaindb.db.utils import Connection +from bigchaindb.backend import connect def test_run_a_simple_query(): - conn = Connection() + conn = connect() query = r.expr('1') assert conn.run(query) == '1' @@ -17,7 +17,7 @@ def test_raise_exception_when_max_tries(): def run(self, conn): raise r.ReqlDriverError('mock') - conn = Connection() + conn = connect() with pytest.raises(r.ReqlDriverError): conn.run(MockQuery()) @@ -30,7 +30,7 @@ def test_reconnect_when_connection_lost(): def raise_exception(*args, **kwargs): raise r.ReqlDriverError('mock') - conn = Connection() + conn = connect() original_connect = r.connect r.connect = raise_exception @@ -75,7 +75,6 @@ def test_changefeed_reconnects_when_connection_lost(monkeypatch): else: time.sleep(10) - bigchain = Bigchain() bigchain.connection = MockConnection() changefeed = ChangeFeed('cat_facts', ChangeFeed.INSERT,