fix syntax
This commit is contained in:
@@ -13,7 +13,10 @@ from assistant_bot.storage import AssistantStorage
|
||||
|
||||
class ReminderParserTests(unittest.TestCase):
|
||||
def test_supported_relative_unit(self) -> None:
|
||||
self.assertEqual(unit_to_timedelta(2, "часа").total_seconds(), 7200)
|
||||
delta = unit_to_timedelta(2, "часа")
|
||||
self.assertIsNotNone(delta)
|
||||
assert delta is not None
|
||||
self.assertEqual(delta.total_seconds(), 7200)
|
||||
|
||||
def test_absolute_datetime(self) -> None:
|
||||
result = parse_reminder(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
from assistant_bot.jobs import post_init, post_shutdown
|
||||
@@ -10,11 +11,11 @@ class ReminderJobLifecycleTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_reminder_task_is_cancelled_on_shutdown(self) -> None:
|
||||
started = asyncio.Event()
|
||||
|
||||
async def fake_reminder_loop(application) -> None:
|
||||
async def fake_reminder_loop(_application) -> None:
|
||||
started.set()
|
||||
await asyncio.Event().wait()
|
||||
|
||||
application = SimpleNamespace(bot_data={})
|
||||
application: Any = SimpleNamespace(bot_data={})
|
||||
with patch("assistant_bot.jobs.reminder_loop", fake_reminder_loop):
|
||||
await post_init(application)
|
||||
await started.wait()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import Any
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
from assistant_bot.handlers import private_voice
|
||||
@@ -15,7 +16,7 @@ class VoiceHandlerTests(unittest.IsolatedAsyncioTestCase):
|
||||
voice=SimpleNamespace(duration=duration, file_id="voice-file-id"),
|
||||
reply_text=AsyncMock(return_value=status_message),
|
||||
)
|
||||
update = SimpleNamespace(message=message)
|
||||
update: Any = SimpleNamespace(message=message)
|
||||
telegram_file = SimpleNamespace(download_to_drive=AsyncMock())
|
||||
bot = SimpleNamespace(
|
||||
get_file=AsyncMock(return_value=telegram_file),
|
||||
@@ -23,7 +24,7 @@ class VoiceHandlerTests(unittest.IsolatedAsyncioTestCase):
|
||||
)
|
||||
recognizer = MagicMock()
|
||||
recognizer.transcribe.return_value = transcript
|
||||
context = SimpleNamespace(
|
||||
context: Any = SimpleNamespace(
|
||||
bot=bot,
|
||||
application=SimpleNamespace(
|
||||
bot_data={
|
||||
|
||||
@@ -38,6 +38,15 @@ class FakeChatCompletions:
|
||||
return self.completion
|
||||
|
||||
|
||||
class FakeHTTPError(RuntimeError):
|
||||
def __init__(self) -> None:
|
||||
super().__init__("forbidden")
|
||||
self.response = SimpleNamespace(
|
||||
status_code=403,
|
||||
text='{"error":{"message":"folder mismatch"}}',
|
||||
)
|
||||
|
||||
|
||||
class YandexAIClientTests(unittest.IsolatedAsyncioTestCase):
|
||||
def test_multiple_system_messages_are_merged_at_the_beginning(self) -> None:
|
||||
self.assertEqual(
|
||||
@@ -62,11 +71,7 @@ class YandexAIClientTests(unittest.IsolatedAsyncioTestCase):
|
||||
)
|
||||
|
||||
def test_http_error_includes_safe_response_body(self) -> None:
|
||||
error = RuntimeError("forbidden")
|
||||
error.response = SimpleNamespace(
|
||||
status_code=403,
|
||||
text='{"error":{"message":"folder mismatch"}}',
|
||||
)
|
||||
error = FakeHTTPError()
|
||||
|
||||
self.assertEqual(
|
||||
describe_yandex_error(error),
|
||||
|
||||
Reference in New Issue
Block a user