Sentinal uses pytest for testing. The suite covers unit tests for core components and integration tests for major workflows.
Install development dependencies:
pip install -r requirements-dev.txtRun all tests:
pytestRun specific category:
pytest tests/unit
pytest tests/integrationGenerate coverage report:
pytest --cov=src --cov-report=htmlThe Sentinal test suite is built on pytest and follows a layered architecture to ensure isolation and reliability.
- Unit Tests (
tests/unit/): Test individual components in isolation. External dependencies (ArXiv API, Google Gemini, Database) are always mocked. - Integration Tests (
tests/integration/): Test the flow between components. These use a temporary local database (SQLite) and mock external network calls, but verify that components interact correctly (e.g., Researcher -> Database -> RAG). - Fixtures (
tests/conftest.py): Shared setup code.mock_settings: Overridessrc.core.config.settingsto prevent loading real.envfiles.managed_db: Creates a temporary SQLite database for integration tests.
We use unittest.mock and pytest-mock to detach from external systems:
- ArXiv Client: Mocked to return predefined
Resultobjects. - LLM (Gemini): Mocked to return static JSON strings avoiding API costs.
- Database: Unit tests mock the DB calls; Integration tests use a fresh DB file per session.
- No External Calls: Tests must run without internet access (except for installing deps).
- Speed: Unit tests should execute in milliseconds.
- Coverage: New features must include tests. Run
pytest --cov=srcto verify.
Tests are configured to run on every PR. Ensure 60% coverage minimum.