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.
65 lines
2.0 KiB
Markdown
65 lines
2.0 KiB
Markdown
# Guilan ACE Backend
|
|
|
|
## Stack
|
|
- Django 5 with Ninja API routers
|
|
- PostgreSQL, Redis, Celery, Gunicorn
|
|
- Prometheus instrumentation through `django-prometheus`
|
|
|
|
## Layout
|
|
```text
|
|
guilan-ace-backend/
|
|
apps/
|
|
users/
|
|
blog/
|
|
gallery/
|
|
events/
|
|
communications/
|
|
payments/
|
|
certificates/
|
|
core/
|
|
config/
|
|
static/
|
|
templates/
|
|
manage.py
|
|
```
|
|
|
|
## Local setup
|
|
```bash
|
|
python -m venv .venv
|
|
.venv\\Scripts\\activate
|
|
pip install -r requirements.txt
|
|
cp .env.example .env
|
|
python manage.py migrate
|
|
python manage.py runserver
|
|
```
|
|
|
|
## Tests
|
|
|
|
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`.
|
|
- Shared base models, admin helpers, choices, and template tags live under `core/`.
|
|
|
|
## Project-local skills
|
|
|
|
Backend implementation guidance is vendored in `.agents/skills/`: `api-and-interface-design`, `deprecation-and-migration`, and `test-driven-development`. Shared team guidance is also included: `grill-me`, `grilling`, `planning-and-task-breakdown`, `documentation-and-adrs`, and `git-workflow-and-versioning`. These directories are part of this repository so they are available after cloning it.
|