SilverElixir commited on
Commit
02a12e4
·
1 Parent(s): fc369dc

Re-audit fixes: typing-indicator regression test, Deno proxy tests in CI

Browse files
Files changed (3) hide show
  1. .github/workflows/ci.yml +7 -0
  2. README.md +1 -1
  3. tests/test_bot_state.py +11 -0
.github/workflows/ci.yml CHANGED
@@ -37,6 +37,13 @@ jobs:
37
 
38
  - run: pytest -q
39
 
 
 
 
 
 
 
 
40
  # проверка requirements.txt на известные CVE в зафиксированных версиях —
41
  # requirements-dev.txt (pytest/pyflakes/pip-audit) не сканируем: это
42
  # dev-инструменты, не попадающие в рантайм-образ (см. Dockerfile/.dockerignore)
 
37
 
38
  - run: pytest -q
39
 
40
+ # Deno-тесты прокси (proxy/proxy_test.ts — без внешних импортов, офлайн).
41
+ - uses: denoland/setup-deno@v2
42
+ with:
43
+ deno-version: v2.x
44
+
45
+ - run: deno test proxy/proxy_test.ts
46
+
47
  # проверка requirements.txt на известные CVE в зафиксированных версиях —
48
  # requirements-dev.txt (pytest/pyflakes/pip-audit) не сканируем: это
49
  # dev-инструменты, не попадающие в рантайм-образ (см. Dockerfile/.dockerignore)
README.md CHANGED
@@ -131,7 +131,7 @@ pytest -v
131
 
132
  Test files live in `tests/` and mirror the module split: `test_lumen_formatting.py`, `test_lumen_security.py`, `test_lumen_router_config.py`, `test_lumen_typing_pace.py`, `test_lumen_images.py`, and `test_lumen_model_speed.py` each test their matching module directly, while `test_bot_admin.py`, `test_bot_commands.py`, `test_bot_routes.py`, `test_bot_state.py`, `test_bot_streaming.py`, `test_bot_tiktok.py`, `test_bot_transport.py`, and `test_bot_tts.py` cover `bot.py` by domain (shared fakes live in `bot_test_helpers.py`). `conftest.py` stubs `BOT_TOKEN`/`GEMINI_API_KEY`/`BOT_LOG_PATH` so the suite needs no real secrets.
133
 
134
- CI (`.github/workflows/ci.yml`) runs `pyflakes` + `pytest` + `pip-audit` on every push and pull request; a successful run triggers `sync-to-hf.yml`, which mirrors the commit to the Hugging Face Space.
135
 
136
  ## Known limitations
137
 
 
131
 
132
  Test files live in `tests/` and mirror the module split: `test_lumen_formatting.py`, `test_lumen_security.py`, `test_lumen_router_config.py`, `test_lumen_typing_pace.py`, `test_lumen_images.py`, and `test_lumen_model_speed.py` each test their matching module directly, while `test_bot_admin.py`, `test_bot_commands.py`, `test_bot_routes.py`, `test_bot_state.py`, `test_bot_streaming.py`, `test_bot_tiktok.py`, `test_bot_transport.py`, and `test_bot_tts.py` cover `bot.py` by domain (shared fakes live in `bot_test_helpers.py`). `conftest.py` stubs `BOT_TOKEN`/`GEMINI_API_KEY`/`BOT_LOG_PATH` so the suite needs no real secrets.
133
 
134
+ CI (`.github/workflows/ci.yml`) runs `pyflakes` + `pytest` + `pip-audit` + `deno test` on every push and pull request; a successful run triggers `sync-to-hf.yml`, which mirrors the commit to the Hugging Face Space.
135
 
136
  ## Known limitations
137
 
tests/test_bot_state.py CHANGED
@@ -4,6 +4,7 @@ test_bot_state.py — Состояние и утилиты: хранилище,
4
  Выделено из test_bot.py (P2 аудита); общие фейки — в bot_test_helpers.py.
5
  """
6
  from types import SimpleNamespace
 
7
  from unittest.mock import MagicMock
8
  from unittest.mock import patch
9
  import asyncio
@@ -502,6 +503,16 @@ def test_ordinary_question_gets_no_file_notice(rate_guard_setup, monkeypatch):
502
  assert "[Служебная пометка" not in prompt
503
 
504
 
 
 
 
 
 
 
 
 
 
 
505
  def test_media_question_with_attached_file_gets_no_file_notice(rate_guard_setup, monkeypatch):
506
  message = rate_guard_setup()
507
  message.text = "что на фото?"
 
4
  Выделено из test_bot.py (P2 аудита); общие фейки — в bot_test_helpers.py.
5
  """
6
  from types import SimpleNamespace
7
+ from unittest.mock import AsyncMock
8
  from unittest.mock import MagicMock
9
  from unittest.mock import patch
10
  import asyncio
 
503
  assert "[Служебная пометка" not in prompt
504
 
505
 
506
+ def test_message_core_sends_typing_indicator(rate_guard_setup, monkeypatch):
507
+ # Регрессия: вызов шёл в bot.send_chat_action (такой функции нет) вместо bot.bot.send_chat_action — индикатор "печатает" молча не показывался.
508
+ message = rate_guard_setup()
509
+ message.text = "столица Венгрии?"
510
+ fake_bot = SimpleNamespace(send_chat_action=AsyncMock())
511
+ monkeypatch.setattr(bot, "bot", fake_bot)
512
+ _run_core_capturing_prompt(message, monkeypatch)
513
+ fake_bot.send_chat_action.assert_awaited_once_with(chat_id=123, action="typing")
514
+
515
+
516
  def test_media_question_with_attached_file_gets_no_file_notice(rate_guard_setup, monkeypatch):
517
  message = rate_guard_setup()
518
  message.text = "что на фото?"