agentleFS
radif-ruradif-ru/ai-multi-agent-system/.agents/skills/testing-discipline/SKILL.md

testing-discipline

Skill6 starsChanged 4 months agoMITView on GitHub

Дисциплина тестов проекта: pytest + asyncio, моки внешних систем, без сети, тест на новое поведение, целевое покрытие.

  • Reads credentials

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

Skill: testing-discipline

Правила тестирования этого проекта. Источник истины — _docs/testing.md и _docs/instructions.md §8.

Когда использовать

  • Пишешь или меняешь код в app/ — нужен unit-тест на новое поведение.
  • Готовишь задачу к коммиту — нужен зелёный pytest -q.
  • Чинишь баг — нужен падающий тест, воспроизводящий дефект.

Не использовать для чисто-документационных задач (правят только _docs/, _board/, README.md, .env.example, app/skills/, app/prompts/) — они освобождены от теста, в DoD ставится n/a.

Алгоритм

  1. Размести тест зеркально коду: tests/<пакет>/test_<name>.py.
  2. Используй pytest + pytest-asyncio (asyncio_mode = "auto"), фикстуру mocker.
  3. Замокай все внешние системы (никакой реальной сети):
    • Telegram: Message/Bot → MagicMock/AsyncMock;
    • Ollama: mocker.patch.object(client, "chat"/"embed", ...);
    • ddgs: mocker.patch("ddgs.DDGS.text", ...);
    • httpx: MockTransport/respx;
    • app/skills/, app/prompts/: путь → tmp_path.
  4. Исключение: SemanticMemory тестируй с реальным sqlite-vec на tmp_path; если extension не грузится — pytest.skip.
  5. Покрой happy path, ошибки домена (ToolError, LLMTimeout, LLMUnavailable, LLMBadResponse, ArgsValidationError), границы (пустой результат, усечение до лимита, превышение лимитов цикла).
  6. При необходимости проверь логи через caplog (step=, tool=<name>, status=).
  7. Прогон: pytest -q — зелёный. Цель покрытия: app/ ≥ 70%, services//agents//tools/ ≥ 85%, app/agents/protocol.py — 100%.

Чего избегать

  • Реальных вызовов Telegram / Ollama / интернета.
  • Маскировки падений через pytest -k/skip вместо починки.
  • Ослабления или удаления существующих тестов без явного указания.
  • Недетерминизма (зависимость от времени, порядка, внешних данных).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.