fix linter, fix ci, fix tests

This commit is contained in:
2026-02-02 00:46:44 +03:00
parent 68041037bd
commit d87d4e492e
93 changed files with 1042 additions and 862 deletions

View File

@@ -3,12 +3,9 @@ from unittest.mock import AsyncMock, Mock, patch
import pytest
from aiogram import types
from aiogram.fsm.context import FSMContext
from helper_bot.handlers.admin.exceptions import (
InvalidInputError,
UserAlreadyBannedError,
UserNotFoundError,
)
from helper_bot.handlers.admin.exceptions import (InvalidInputError,
UserAlreadyBannedError,
UserNotFoundError)
from helper_bot.handlers.admin.services import AdminService, BannedUser, User
@@ -230,7 +227,9 @@ class TestAdminService:
return_value=[(1, "спам", None), (2, "оскорбления", "2025-02-01")]
)
self.mock_db.get_username = AsyncMock(side_effect=["user1", "user2"])
self.mock_db.get_full_name_by_id = AsyncMock(side_effect=["Name One", "Name Two"])
self.mock_db.get_full_name_by_id = AsyncMock(
side_effect=["Name One", "Name Two"]
)
result = await self.admin_service.get_banned_users()
@@ -244,7 +243,9 @@ class TestAdminService:
@pytest.mark.asyncio
async def test_get_banned_users_uses_user_id_fallback(self):
"""get_banned_users при отсутствии username/full_name использует User_{id}."""
self.mock_db.get_banned_users_from_db = AsyncMock(return_value=[(99, "reason", None)])
self.mock_db.get_banned_users_from_db = AsyncMock(
return_value=[(99, "reason", None)]
)
self.mock_db.get_username = AsyncMock(return_value=None)
self.mock_db.get_full_name_by_id = AsyncMock(return_value=None)
@@ -256,8 +257,14 @@ class TestAdminService:
@pytest.mark.asyncio
async def test_get_banned_users_for_display_success(self):
"""Тест успешного получения данных для отображения забаненных."""
with patch("helper_bot.handlers.admin.services.get_banned_users_list", new_callable=AsyncMock) as mock_list:
with patch("helper_bot.handlers.admin.services.get_banned_users_buttons", new_callable=AsyncMock) as mock_buttons:
with patch(
"helper_bot.handlers.admin.services.get_banned_users_list",
new_callable=AsyncMock,
) as mock_list:
with patch(
"helper_bot.handlers.admin.services.get_banned_users_buttons",
new_callable=AsyncMock,
) as mock_buttons:
mock_list.return_value = "Список забаненных"
mock_buttons.return_value = []