| name | testing-workflows |
| description | Test bot functionality locally using CLI runner, message simulation, and workflow validation. Trigger on "test", "CLI runner", "message simulation", "bot testing", "workflow validation", "pytest". |
| version | 2.0.1 |
| allowed-tools | Bash, Read, Write |
Testing Workflows Skill
Test bot functionality locally using CLI tools, message simulation, and unit tests.
CLI Summary Runner
The CLI runner tests the full URL processing pipeline without Telegram credentials.
Telegram credentials (API_ID, API_HASH, BOT_TOKEN) are NOT required -- the CLI generates stub credentials automatically.
Basic Usage
python -m app.cli.summary --url https://example.com/article
python -m app.cli.summary \
--url https://example.com/article \
--json-path summary.json \
--log-level DEBUG
python -m app.cli.summary \
--url "https://example.com/1 https://example.com/2" \
--accept-multiple
python -m app.cli.summary "/summarize https://example.com/article"
CLI Features
- Full pipeline: URL normalization -> scraper chain -> LLM -> JSON validation
- Deduplication: Respects
dedupe_hash (won't re-crawl same URL)
- Insights generation: Optional advanced analysis with retry logic
- JSON repair: Handles malformed LLM output
- Correlation IDs: Generates unique IDs for tracing
Testing Specific Workflows
Standalone test scripts are bundled with this skill in ./scripts/. Run them directly:
.venv/bin/python .codex/skills/testing-workflows/scripts/test-url-normalization.py
.venv/bin/python .codex/skills/testing-workflows/scripts/test-summary-validation.py
.venv/bin/python .codex/skills/testing-workflows/scripts/test-language-detection.py
.venv/bin/python .codex/skills/testing-workflows/scripts/test-access-control.py
Simulating Telegram Messages
Message Models
Telegram adapters receive Telethon message objects. Follow existing fixtures and MagicMock/SimpleNamespace shapes in tests/adapters/telegram/ and tests/test_command_dispatcher.py; do not invent a parallel Telegram message model.
Test Message Router
For routing logic tests, instantiate MessageRouter with mocked dependencies and call it directly. See app/adapters/telegram/message_router.py for the constructor signature and existing router tests under tests/adapters/telegram/ for setup patterns.
End-to-End URL Flow
python -m app.cli.summary \
--url https://example.com/article \
--json-path test_output.json \
--log-level DEBUG
python -m json.tool test_output.json
docker exec -i ratatoskr-postgres psql -U ratatoskr_app -d ratatoskr -c \
"SELECT id, type, status, input_url
FROM requests
ORDER BY created_at DESC
LIMIT 1;"
Error Handling
python -m app.cli.summary --url "not-a-url"
python -m app.cli.summary --url "https://thisurldoesnotexist12345.com"
docker exec -i ratatoskr-postgres psql -U ratatoskr_app -d ratatoskr -c \
"SELECT id, status, input_url
FROM requests
WHERE status = 'error'
ORDER BY created_at DESC
LIMIT 5;"
Running pytest
python -m pytest tests/ -v
python -m pytest tests/test_url_utils.py -v
python -m pytest tests/ --cov=app --cov-report=html
References
references/bot-commands.md -- Available bot commands and processing flow
references/e2e-testing.md -- Docker testing and E2E test setup
Key Files
- CLI Runner:
app/cli/summary.py
- Message Router:
app/adapters/telegram/message_router.py
- Access Controller:
app/adapters/telegram/access_controller.py
- URL Handler:
app/adapters/telegram/url_handler.py
- Command Dispatcher:
app/adapters/telegram/command_dispatcher.py, app/adapters/telegram/command_dispatch/
Important Notes
- CLI runner does NOT send actual Telegram messages
- Database operations work exactly like production
- The summary validation script exercises both the strict provider schema and the tolerant compatibility mapper used by the live workflow
- Use correlation IDs to trace requests across logs and DB
- Test both English and Russian language flows