test: migrate backend suites to pytest with module coverage gate
Split backend tests into unit and integration suites, add isolated fixtures and coverage enforcement, and update CI and test documentation. Cover current authentication, content, notification, payment, media, and admin flows; fix behaviors revealed by the new tests. Validate both suites and the per-module gate against local PostgreSQL.
This commit is contained in:
20
README.md
20
README.md
@@ -34,10 +34,26 @@ python manage.py runserver
|
||||
```
|
||||
|
||||
## Tests
|
||||
```bash
|
||||
python manage.py test --settings=config.settings.test
|
||||
|
||||
Install test dependencies, then run the two pytest suites:
|
||||
|
||||
```powershell
|
||||
python -m pip install -r requirements-test.txt
|
||||
python -m pytest -m unit
|
||||
python -m pytest -m integration
|
||||
```
|
||||
|
||||
CI uses PostgreSQL for integration tests and combines branch coverage from both suites. The same coverage gate can be run locally after configuring the test database:
|
||||
|
||||
```powershell
|
||||
python -m coverage run -m pytest -m unit
|
||||
python -m coverage run --append -m pytest -m integration
|
||||
python -m coverage json -o coverage.json
|
||||
python scripts/check_coverage.py coverage.json --minimum 80
|
||||
```
|
||||
|
||||
Coverage includes executable modules in `apps`, `core`, and `config`. The fixed exclusions are migrations, tests, `__init__.py`, `apps.py`, `config/settings`, ASGI/WSGI entrypoints, and constant-only service config modules (`location`, `notifications`, and `zarinpal`). Every included module must reach 80% combined statement and branch coverage.
|
||||
|
||||
## Notes
|
||||
- Domain routers live under `apps/<domain>/api`.
|
||||
- Shared auth helpers live in `core/authentication.py`.
|
||||
|
||||
Reference in New Issue
Block a user