fix(tg): QA fixes — stream_message, topic_created, archive reply

- sdk/mock.py: stream_message was async def (coroutine), must be async
  generator with yield — caused TypeError on every user message
- topic_events.py: on_topic_created now skips bot-created topics
  (from_user.id == bot.id); cmd_new already registers them under the
  correct human user_id
- commands.py: cmd_archive now sends "Чат архивирован." confirmation
- test_topic_events.py: add bot=SimpleNamespace(id=BOT_ID) to fixture
This commit is contained in:
Mikhail Putilovskij 2026-04-02 14:14:19 +03:00
parent 8901e60f6a
commit d5ab527f5d
4 changed files with 20 additions and 13 deletions

View file

@ -16,6 +16,9 @@ def fresh_db(tmp_path, monkeypatch):
return db_mod
BOT_ID = 9999 # distinct from any test user_id
def make_service_message(*, user_id=1, thread_id=42, topic_name="Мой чат"):
m = SimpleNamespace()
m.message_thread_id = thread_id
@ -25,6 +28,7 @@ def make_service_message(*, user_id=1, thread_id=42, topic_name="Мой чат")
m.forum_topic_edited = SimpleNamespace(name="Новое имя")
m.forum_topic_closed = SimpleNamespace()
m.answer = AsyncMock()
m.bot = SimpleNamespace(id=BOT_ID)
return m