Testing Strategy
Test suite location:
tests/
Run Tests
pytest -q
pytest -q --cov=keynetra --cov-fail-under=80
For quick local iteration, run targeted test modules:
pytest -q tests/test_engine.py
pytest -q tests/test_api.py
Coverage Areas
Current test modules validate:
- engine behavior and explainability
- API contract and route behavior
- ACL operations
- relationship indexing
- compiled policies and policy simulation
- impact analysis
- auth model parsing/validation/compile flow
- revision consistency and caching behavior
- metrics endpoint output
- admin login flow
- migration safety utilities
- release hardening checks
- headless and CLI modes
Representative files:
tests/test_engine.pytests/test_api.pytests/test_api_contract.pytests/test_acl.pytests/test_auth_model.pytests/test_policy_simulation.pytests/test_impact_analysis.pytests/test_metrics_endpoint.pytests/test_services_caching.pytests/test_headless_modes.py
Policy Test Suites
Policy-specific deterministic testing via CLI:
python -m keynetra.cli test-policy ./policy_tests.yaml
CI Expectations
CI validates lint, migration application, and coverage thresholds. Match those checks locally before opening a PR.