Fix misc tests affected by changes related to database abstraction

This commit is contained in:
Brett Sun 2016-12-05 20:13:12 +01:00 committed by Sylvain Bellemare
parent 9e3bca7e85
commit 941b47d1ac
3 changed files with 7 additions and 8 deletions

View File

@ -1,7 +1,7 @@
from unittest.mock import patch from unittest.mock import patch
from multipipes import Pipe from multipipes import Pipe
from bigchaindb.db.utils import Connection from bigchaindb.backend.connection import Connection
from bigchaindb.pipelines.utils import ChangeFeed from bigchaindb.pipelines.utils import ChangeFeed

View File

@ -62,12 +62,12 @@ def test_bigchain_class_initialization_with_parameters(config):
def test_get_blocks_status_containing_tx(monkeypatch): 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 from bigchaindb.core import Bigchain
blocks = [ blocks = [
{'id': 1}, {'id': 2} {'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) monkeypatch.setattr(Bigchain, 'block_election_status', lambda x, y, z: Bigchain.BLOCK_VALID)
bigchain = Bigchain(public_key='pubkey', private_key='privkey') bigchain = Bigchain(public_key='pubkey', private_key='privkey')
with pytest.raises(Exception): with pytest.raises(Exception):

View File

@ -3,11 +3,11 @@ import pytest
import rethinkdb as r import rethinkdb as r
from bigchaindb.db.utils import Connection from bigchaindb.backend import connect
def test_run_a_simple_query(): def test_run_a_simple_query():
conn = Connection() conn = connect()
query = r.expr('1') query = r.expr('1')
assert conn.run(query) == '1' assert conn.run(query) == '1'
@ -17,7 +17,7 @@ def test_raise_exception_when_max_tries():
def run(self, conn): def run(self, conn):
raise r.ReqlDriverError('mock') raise r.ReqlDriverError('mock')
conn = Connection() conn = connect()
with pytest.raises(r.ReqlDriverError): with pytest.raises(r.ReqlDriverError):
conn.run(MockQuery()) conn.run(MockQuery())
@ -30,7 +30,7 @@ def test_reconnect_when_connection_lost():
def raise_exception(*args, **kwargs): def raise_exception(*args, **kwargs):
raise r.ReqlDriverError('mock') raise r.ReqlDriverError('mock')
conn = Connection() conn = connect()
original_connect = r.connect original_connect = r.connect
r.connect = raise_exception r.connect = raise_exception
@ -75,7 +75,6 @@ def test_changefeed_reconnects_when_connection_lost(monkeypatch):
else: else:
time.sleep(10) time.sleep(10)
bigchain = Bigchain() bigchain = Bigchain()
bigchain.connection = MockConnection() bigchain.connection = MockConnection()
changefeed = ChangeFeed('cat_facts', ChangeFeed.INSERT, changefeed = ChangeFeed('cat_facts', ChangeFeed.INSERT,