Skip to content

Commit 53a4f98

Browse files
committed
feat(api): run tests using pytest
1 parent bdc4018 commit 53a4f98

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ While there are certainly many ways to get started hacking desec-stack, here is
334334
source venv/bin/activate
335335
pip install wheel
336336
pip install -r requirements.txt
337+
pip install -r requirements-test.txt
337338

338339
1. At this point, Django is ready to run in the virtual environment created above.
339340
There are two things to consider when running Django outside the container.
@@ -359,10 +360,9 @@ While there are certainly many ways to get started hacking desec-stack, here is
359360

360361
docker compose -f docker-compose.yml -f docker-compose.test-api.yml up -d dbapi
361362

362-
Finally, you can manage Django using the `manage.py` CLI.
363-
As an example, to run the tests, use
363+
To run the tests, in `/api` use
364364

365-
python3 manage.py test
365+
pytest
366366

367367
1. Open the project root directory `desec-stack` in PyCharm and select File › Settings.
368368
1. In Project: desec-stack › Project Structure, mark the `api/` folder as a source folder.

api/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ WORKDIR /usr/src/app
1111
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
1212
ENV PIP_NO_CACHE_DIR=1
1313

14-
COPY requirements.txt /usr/src/app/
14+
COPY requirements*.txt /usr/src/app/
1515
# freetype-dev is needed for captcha generation
1616
RUN apk add --no-cache gcc freetype-dev libffi-dev musl-dev libmemcached-dev postgresql-dev jpeg-dev zlib-dev
1717
RUN pip install --upgrade pip \
1818
&& pip install -r requirements.txt \
19+
&& pip install -r requirements-test.txt \
1920
&& pip freeze
2021

2122
RUN mkdir /root/cronhook

api/entrypoint-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ echo "waiting for dependencies ..."
99
/root/cronhook/start-cron.sh &
1010

1111
echo Starting API tests ...
12-
coverage run --source='.' manage.py test -v 3 --noinput
12+
coverage run --source='.' -m pytest
1313
coverage report

api/pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
DJANGO_SETTINGS_MODULE = api.settings

api/requirements-test.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage~=7.8.0
2+
pytest-django~=4.11.1

api/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
captcha~=0.7.1
22
celery~=5.4.0
3-
coverage~=7.8.0
43
cryptography~=44.0.2
54
Django~=5.1.7
65
django-cors-headers~=4.7.0

0 commit comments

Comments
 (0)