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:
@@ -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):
|
||||
"""Тест получения кнопок заблокированных пользователей"""
|
||||
|
||||
Reference in New Issue
Block a user