1.8 KiB
1.8 KiB
Testing nomyo-router
Setup
Install test dependencies (from the project root):
pip install -r test/requirements_test.txt
Running tests
All commands run from the test/ directory:
cd test
All non-integration tests (no backend required):
pytest -m "not integration" -v
Integration tests only (requires backend at 192.168.0.51:12434):
pytest -m integration -v
Everything:
pytest -v
Test structure
| File | What it covers | Backend needed |
|---|---|---|
test_unit_helpers.py |
Pure helper functions (_mask_secrets, _is_fresh, ep2base, etc.) |
No |
test_unit_transforms.py |
Message transform functions (tool calls, image stripping, etc.) | No |
test_unit_context.py |
Context window trimming logic | No |
test_fetch.py |
fetch.available_models / fetch.loaded_models with mocked HTTP |
No |
test_choose_endpoint.py |
choose_endpoint routing logic with mocked fetch layer |
No |
test_api_validation.py |
HTTP 400/401/403 validation and auth middleware (in-process app) | No |
test_api_integration.py |
Full request/response against a real Ollama/llama-server backend | Yes |
Integration test backend
Integration tests start the router in-process via startup_event() and route traffic
through httpx.ASGITransport — no separately running router instance is needed.
They do require a reachable Ollama or llama-server backend. Override the defaults via environment variables:
export NOMYO_TEST_OLLAMA=http://192.168.0.51:12434
export NOMYO_TEST_EMBED_MODEL=nomic-embed-text # optional, auto-discovered otherwise
export NOMYO_TEST_MODEL_CHAT=llama3.2 # optional, auto-discovered otherwise
If the backend is unreachable, integration tests are automatically skipped.