refactored
Some checks failed
Deploy on push / deploy (push) Failing after 6s

This commit is contained in:
2025-08-17 17:56:31 +03:00
parent e78e12eeee
commit 9a2b792f08
98 changed files with 702 additions and 904 deletions

View File

@@ -9,7 +9,7 @@ import pytest
import redis.asyncio as aioredis
from redis.asyncio import Redis
from services.redis import (
from storage.redis import (
RedisService,
close_redis,
init_redis,
@@ -28,7 +28,7 @@ class TestRedisServiceInitialization:
def test_redis_service_init_without_aioredis(self):
"""Тест инициализации без aioredis"""
with patch("services.redis.aioredis", None):
with patch("storage.redis.aioredis", None):
service = RedisService()
assert service._is_available is False
@@ -58,7 +58,7 @@ class TestRedisConnectionManagement:
"""Тест успешного подключения"""
service = RedisService()
with patch("services.redis.aioredis.from_url") as mock_from_url:
with patch("storage.redis.aioredis.from_url") as mock_from_url:
mock_client = AsyncMock()
mock_client.ping = AsyncMock(return_value=True)
mock_from_url.return_value = mock_client
@@ -73,7 +73,7 @@ class TestRedisConnectionManagement:
"""Тест неудачного подключения"""
service = RedisService()
with patch("services.redis.aioredis.from_url") as mock_from_url:
with patch("storage.redis.aioredis.from_url") as mock_from_url:
mock_from_url.side_effect = Exception("Connection failed")
await service.connect()
@@ -84,7 +84,7 @@ class TestRedisConnectionManagement:
@pytest.mark.asyncio
async def test_connect_without_aioredis(self):
"""Тест подключения без aioredis"""
with patch("services.redis.aioredis", None):
with patch("storage.redis.aioredis", None):
service = RedisService()
await service.connect()
assert service._client is None
@@ -96,7 +96,7 @@ class TestRedisConnectionManagement:
mock_existing_client = AsyncMock()
service._client = mock_existing_client
with patch("services.redis.aioredis.from_url") as mock_from_url:
with patch("storage.redis.aioredis.from_url") as mock_from_url:
mock_client = AsyncMock()
mock_client.ping = AsyncMock(return_value=True)
mock_from_url.return_value = mock_client
@@ -149,7 +149,7 @@ class TestRedisCommandExecution:
@pytest.mark.asyncio
async def test_execute_without_aioredis(self):
"""Тест выполнения команды без aioredis"""
with patch("services.redis.aioredis", None):
with patch("storage.redis.aioredis", None):
service = RedisService()
result = await service.execute("test_command")
assert result is None
@@ -874,7 +874,7 @@ class TestAdditionalRedisCoverage:
service._client = mock_client
mock_client.close.side_effect = Exception("Close error")
with patch('services.redis.aioredis.from_url') as mock_from_url:
with patch('storage.redis.aioredis.from_url') as mock_from_url:
mock_new_client = AsyncMock()
mock_from_url.return_value = mock_new_client