This commit is contained in:
@@ -64,7 +64,7 @@ class TestRedisConnectionManagement:
|
||||
"""Тест неудачного подключения"""
|
||||
service = RedisService()
|
||||
|
||||
with patch("storage.redis.aioredis.from_url") as mock_from_url:
|
||||
with patch("storage.redis.aioredis.ConnectionPool.from_url") as mock_from_url:
|
||||
mock_from_url.side_effect = Exception("Connection failed")
|
||||
|
||||
await service.connect()
|
||||
@@ -852,18 +852,17 @@ class TestAdditionalRedisCoverage:
|
||||
assert service._client is not None
|
||||
|
||||
async def test_disconnect_exception_handling(self):
|
||||
"""Test disconnect with exception"""
|
||||
"""Test disconnect with exception - should log error but not raise"""
|
||||
service = RedisService()
|
||||
mock_client = AsyncMock()
|
||||
service._client = mock_client
|
||||
mock_client.close.side_effect = Exception("Disconnect error")
|
||||
|
||||
# The disconnect method doesn't handle exceptions, so it should raise
|
||||
with pytest.raises(Exception, match="Disconnect error"):
|
||||
await service.close()
|
||||
# The disconnect method handles exceptions gracefully - should not raise
|
||||
await service.close()
|
||||
|
||||
# Since exception is not handled, client remains unchanged
|
||||
assert service._client is mock_client
|
||||
# Client should be set to None even if close() failed
|
||||
assert service._client is None
|
||||
|
||||
async def test_get_and_deserialize_exception(self):
|
||||
"""Test get_and_deserialize with exception"""
|
||||
|
||||
Reference in New Issue
Block a user