Implement user-specific question numbering and update database schema. Added triggers for automatic question numbering and adjustments upon deletion. Enhanced CRUD operations to manage user_question_number effectively.
This commit is contained in:
65
tests/conftest.py
Normal file
65
tests/conftest.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""
|
||||
Конфигурация 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
|
||||
Reference in New Issue
Block a user