ruff fixed formatting
This commit is contained in:
@@ -48,26 +48,20 @@ def clear_redis(raw_redis_client: redis.Redis) -> None:
|
||||
raw_redis_client.flushall()
|
||||
|
||||
|
||||
def test_should_adhere_to_interface(
|
||||
redis_container: str
|
||||
) -> None:
|
||||
def test_should_adhere_to_interface(redis_container: str) -> None:
|
||||
"""Test that the RedisAdapter adheres to the expected interface."""
|
||||
# Instantiation fails if interface not adhered to
|
||||
_ = RedisAdapter()
|
||||
|
||||
|
||||
def test_should_have_logger_when_instantiated(
|
||||
redis_container: str
|
||||
) -> None:
|
||||
def test_should_have_logger_when_instantiated(redis_container: str) -> None:
|
||||
"""Test that the RedisAdapter has a logger when instantiated."""
|
||||
adapter = RedisAdapter()
|
||||
assert hasattr(adapter, "logger")
|
||||
assert adapter.logger is not None
|
||||
|
||||
|
||||
def test_should_not_be_connected_when_instantiated(
|
||||
redis_container: str
|
||||
) -> None:
|
||||
def test_should_not_be_connected_when_instantiated(redis_container: str) -> None:
|
||||
"""Test that the RedisAdapter is not connected when instantiated."""
|
||||
adapter = RedisAdapter()
|
||||
assert adapter._client is None
|
||||
@@ -89,7 +83,7 @@ def test_should_raise_connection_error_when_unable_to_connect(
|
||||
|
||||
|
||||
def test_connect_raises_connection_error_when_unable_to_ping(
|
||||
monkeypatch: pytest.MonkeyPatch
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Test that the RedisAdapter raises ConnectionError when ping fails."""
|
||||
# Set an invalid URI
|
||||
@@ -98,6 +92,7 @@ def test_connect_raises_connection_error_when_unable_to_ping(
|
||||
# Monkeypatch redis.Redis.from_url to return a mock client
|
||||
class MockRedis:
|
||||
"""A mock Redis client that simulates a failed ping."""
|
||||
|
||||
def ping(self) -> bool:
|
||||
"""Simulate a failed ping."""
|
||||
return False # Simulate failed ping
|
||||
@@ -125,9 +120,7 @@ def test_should_log_error_on_exception_during_exit(
|
||||
assert "Error while exiting context" in caplog.text
|
||||
|
||||
|
||||
def test_should_have_context_manager(
|
||||
redis_container: str
|
||||
) -> None:
|
||||
def test_should_have_context_manager(redis_container: str) -> None:
|
||||
"""Test that the RedisAdapter can be used as a context manager."""
|
||||
with RedisAdapter() as adapter:
|
||||
assert adapter._client is not None
|
||||
|
||||
Reference in New Issue
Block a user