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:
19
.github/workflows/backend.yml
vendored
19
.github/workflows/backend.yml
vendored
@@ -27,15 +27,6 @@ jobs:
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- 6379:6379
|
||||
options: >-
|
||||
--health-cmd "redis-cli ping"
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
env:
|
||||
SECRET_KEY: github-ci-secret-key
|
||||
DEBUG: "False"
|
||||
@@ -83,8 +74,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
pip install coverage
|
||||
pip install -r requirements-test.txt
|
||||
|
||||
- name: Prepare environment file
|
||||
run: cp .env.test .env
|
||||
@@ -92,10 +82,13 @@ jobs:
|
||||
- name: Run migrations
|
||||
run: python manage.py migrate --noinput
|
||||
|
||||
- name: Run tests with coverage
|
||||
- name: Run unit and integration tests with coverage
|
||||
run: |
|
||||
coverage run --rcfile=.coveragerc manage.py test apps.users.tests apps.events.tests apps.payments.tests apps.notifications.tests apps.communications.tests core.tests --settings=config.settings.test --verbosity 2
|
||||
coverage run --rcfile=.coveragerc -m pytest -m unit -q
|
||||
coverage run --rcfile=.coveragerc --append -m pytest -m integration -q
|
||||
coverage report -m
|
||||
coverage json -o coverage.json
|
||||
python scripts/check_coverage.py coverage.json --minimum 80
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
Reference in New Issue
Block a user