Merge branch 'fix/1068/break-out-loop-connection'

This commit is contained in:
vrde 2017-01-30 11:57:49 +01:00
commit 18533db10a
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
2 changed files with 15 additions and 0 deletions

View File

@ -77,3 +77,5 @@ class RethinkDBConnection(Connection):
wait_time = 2**i
logging.debug('Error connecting to database, waiting %ss', wait_time)
time.sleep(wait_time)
else:
break

View File

@ -1,6 +1,7 @@
import time
import multiprocessing as mp
from threading import Thread
from unittest.mock import patch
import pytest
import rethinkdb as r
@ -118,3 +119,15 @@ def test_changefeed_reconnects_when_connection_lost(monkeypatch):
fact = changefeed.outqueue.get()['fact']
assert fact == 'Cats sleep 70% of their lives.'
@patch('rethinkdb.connect')
def test_connection_happens_one_time_if_successful(mock_connect):
from bigchaindb.backend import connect
query = r.expr('1')
conn = connect('rethinkdb', 'localhost', 1337, 'whatev')
conn.run(query)
mock_connect.assert_called_once_with(host='localhost',
port=1337,
db='whatev')