Skip to content

Commit

Permalink
Fix instance info tests for redis. (#784)
Browse files Browse the repository at this point in the history
* Fix instance info tests for redis.

* [Mega-Linter] Apply linters fixes

---------

Co-authored-by: umaannamalai <umaannamalai@users.noreply.github.com>
  • Loading branch information
umaannamalai and umaannamalai authored Mar 20, 2023
1 parent df9701c commit fbb851e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions tests/datastore_redis/test_instance_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def test_strict_redis_connection_instance_info(args, kwargs, expected):
if (3, 5, 3) >= REDIS_PY_VERSION >= (2, 7, 5):
_instance_info_from_url_tests.append((("redis://127.0.0.1",), {}, ("127.0.0.1", "6379", "0")))


if REDIS_PY_VERSION >= (2, 10):
_instance_info_from_url_tests.extend(
[
Expand All @@ -115,6 +116,13 @@ def test_strict_redis_connection_instance_info(args, kwargs, expected):
]
)

if REDIS_PY_VERSION >= (4, 5, 2):
_instance_info_from_url_tests_4_5_2 = _instance_info_from_url_tests[:-3] + [
(("unix:///path/to/socket.sock",), {}, ("localhost", "6379", "0")),
(("unix:///path/to/socket.sock?db=2",), {}, ("localhost", "6379", "2")),
(("unix:///path/to/socket.sock",), {"db": 2}, ("localhost", "6379", "2")),
]


@pytest.mark.skipif(REDIS_PY_VERSION < (2, 6), reason="from_url not yet implemented in this redis-py version")
@pytest.mark.parametrize("args,kwargs,expected", _instance_info_from_url_tests)
Expand All @@ -133,7 +141,10 @@ def test_strict_redis_client_from_url(args, kwargs, expected):


@pytest.mark.skipif(REDIS_PY_VERSION < (2, 6), reason="from_url not yet implemented in this redis-py version")
@pytest.mark.parametrize("args,kwargs,expected", _instance_info_from_url_tests)
@pytest.mark.parametrize(
"args,kwargs,expected",
_instance_info_from_url_tests if REDIS_PY_VERSION < (4, 5, 2) else _instance_info_from_url_tests_4_5_2,
)
def test_redis_connection_from_url(args, kwargs, expected):
r = redis.Redis.from_url(*args, **kwargs)
if r.connection_pool.connection_class is redis.Connection:
Expand All @@ -153,7 +164,10 @@ def test_redis_connection_from_url(args, kwargs, expected):


@pytest.mark.skipif(REDIS_PY_VERSION < (2, 6), reason="from_url not yet implemented in this redis-py version")
@pytest.mark.parametrize("args,kwargs,expected", _instance_info_from_url_tests)
@pytest.mark.parametrize(
"args,kwargs,expected",
_instance_info_from_url_tests if REDIS_PY_VERSION < (4, 5, 2) else _instance_info_from_url_tests_4_5_2,
)
def test_strict_redis_connection_from_url(args, kwargs, expected):
r = redis.StrictRedis.from_url(*args, **kwargs)
if r.connection_pool.connection_class is redis.Connection:
Expand Down

0 comments on commit fbb851e

Please sign in to comment.