@@ -258,7 +258,7 @@ docker compose -f docker-compose.test.yml up --build -d
258258** Step 5: Run integration tests**
259259``` bash
260260cd backend
261- TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db --run-all
261+ DB_HOST=127.0.0.1 DB_PORT=5435 TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db --run-all
262262```
263263
264264** Step 6: Clean up**
@@ -275,26 +275,33 @@ The test environment uses `backend/kernelCI/test_settings.py` which:
275275- Configures local PostgreSQL database
276276- Sets ` TEST_BASE_URL=http://localhost:8001/ `
277277
278+ Most integration tests are HTTP black-box tests against the running ` test_backend `
279+ container, but some (e.g. management-command tests) are DB-backed and use
280+ ` @pytest.mark.django_db ` with factories. Those connect to PostgreSQL directly from
281+ the host, so the run commands set ` DB_HOST=127.0.0.1 DB_PORT=5435 ` to reach the
282+ ` test_db ` container (published on port ` 5435 ` ); ` pytest-django ` then creates its own
283+ isolated ` test_* ` database, separate from the seeded one used by the HTTP tests.
284+
278285### Running Specific Tests
279286
280287** Run all integration tests:**
281288``` bash
282- TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db --run-all
289+ DB_HOST=127.0.0.1 DB_PORT=5435 TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db --run-all
283290```
284291
285292** Run only a subset of tests (faster):**
286293``` bash
287- TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db
294+ DB_HOST=127.0.0.1 DB_PORT=5435 TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db
288295```
289296
290297** Run specific test file:**
291298``` bash
292- TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db backend/kernelCI_app/tests/integrationTests/< your_test> .py
299+ DB_HOST=127.0.0.1 DB_PORT=5435 TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db backend/kernelCI_app/tests/integrationTests/< your_test> .py
293300```
294301
295302** Run specific method:**
296303``` bash
297- TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db backend/kernelCI_app/tests/integrationTests/< your_test> .py::< your_function>
304+ DB_HOST=127.0.0.1 DB_PORT=5435 TEST_BASE_URL=http://localhost:8001 poetry run pytest -m integration --use-local-db backend/kernelCI_app/tests/integrationTests/< your_test> .py::< your_function>
298305```
299306
300307### Troubleshooting
0 commit comments