Update banned users handling with async support and improved date parsing

- Modified `change_page` function in `callback_handlers.py` to use async methods for retrieving banned users and their buttons.
- Enhanced `get_banned_users_list` in `helper_func.py` to handle string timestamps and various date formats, ensuring robust date parsing.
- Added a new test case in `test_utils.py` to validate the handling of string timestamps in the banned users list retrieval.
This commit is contained in:
2025-09-08 23:19:19 +03:00
parent 5f6882d348
commit 31e29cdec0
3 changed files with 35 additions and 4 deletions

View File

@@ -599,6 +599,24 @@ class TestUtilityFunctions:
assert "Spam" in result
assert "Violation" in result
@pytest.mark.asyncio
async def test_get_banned_users_list_with_string_timestamp(self):
"""Тест получения списка заблокированных пользователей со строковым timestamp"""
mock_db = AsyncMock()
mock_db.get_banned_users_from_db_with_limits.return_value = [
(123, "Spam", "1704067200"), # user_id, ban_reason, unban_date (string timestamp)
(456, "Violation", "1704153600")
]
mock_db.get_username.return_value = None
mock_db.get_full_name_by_id.return_value = "Test User"
result = await get_banned_users_list(0, mock_db)
assert "Список заблокированных пользователей:" in result
assert "Test User" in result
assert "Spam" in result
assert "Violation" in result
@pytest.mark.asyncio
async def test_get_banned_users_buttons(self):
"""Тест получения кнопок заблокированных пользователей"""