66 lines
1.6 KiB
Python
66 lines
1.6 KiB
Python
"""
|
|
Конфигурация pytest для AnonBot
|
|
"""
|
|
import pytest
|
|
import asyncio
|
|
from unittest.mock import AsyncMock, MagicMock
|
|
from typing import Generator
|
|
|
|
# Импорты для фикстур
|
|
from config import config
|
|
from services.infrastructure.database import DatabaseService
|
|
from services.auth.auth_new import AuthService
|
|
from services.validation import InputValidator
|
|
from services.utils import UtilsService
|
|
from services.rate_limiting.rate_limit_service import RateLimitService
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def event_loop():
|
|
"""Создание event loop для async тестов"""
|
|
loop = asyncio.get_event_loop_policy().new_event_loop()
|
|
yield loop
|
|
loop.close()
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_database():
|
|
"""Мок для DatabaseService"""
|
|
return AsyncMock(spec=DatabaseService)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_auth():
|
|
"""Мок для AuthService"""
|
|
return AsyncMock(spec=AuthService)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_validator():
|
|
"""Мок для InputValidator"""
|
|
return MagicMock(spec=InputValidator)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_utils():
|
|
"""Мок для UtilsService"""
|
|
return MagicMock(spec=UtilsService)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_rate_limit_service():
|
|
"""Мок для RateLimitService"""
|
|
return AsyncMock(spec=RateLimitService)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_config():
|
|
"""Мок для конфигурации"""
|
|
mock_config = MagicMock()
|
|
mock_config.ADMINS = [123456789, 987654321]
|
|
mock_config.MAX_QUESTION_LENGTH = 1000
|
|
mock_config.MAX_ANSWER_LENGTH = 2000
|
|
mock_config.MIN_QUESTION_LENGTH = 10
|
|
mock_config.MIN_ANSWER_LENGTH = 5
|
|
return mock_config
|