Skip to content

Commit fd7c625

Browse files
Update test_redis_connect_host.py
Improve unit test for cover coverage.
1 parent 05cff79 commit fd7c625

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/test_redis_connect_host.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ def test_redis_connect_host():
1717
db.dbintf = mock_dbintf
1818
db.dbintf.redis_kwargs = {}
1919

20-
db_name = 'COUNTERS_DB'
21-
host = '127.0.0.1'
20+
counters_db = 'COUNTERS_DB'
21+
host_ip = '127.0.0.1'
2222

23-
db.connect_host(db_name, host)
24-
mock_dbintf.connect.assert_called_once_with(2, db_name, True)
23+
def mocked_connect(db_id, db_name, retry_on):
24+
assert db_id == 2
25+
assert db_name == counters_db
2526

26-
assert db.dbintf.redis_kwargs["host"] == host
27+
db.dbintf.connect = mocked_connect
28+
db.connect_host(counters_db, host_ip)
29+
30+
assert db.dbintf.redis_kwargs["host"] == host_ip
2731
assert db.dbintf.redis_kwargs["port"] == 6379

0 commit comments

Comments
 (0)