From 9946fa7d969a6d7ce7a66a617de60e62b9819578 Mon Sep 17 00:00:00 2001 From: ftsell Date: Mon, 12 Feb 2024 20:02:14 +0100 Subject: [PATCH] add test generation and github action execution --- .github/workflows/test.yml | 2 ++ {{ cookiecutter.project_slug }}/Pipfile | 2 ++ {{ cookiecutter.project_slug }}/pyproject.toml | 8 ++++++++ .../core/tests/__init__.py | 0 .../core/tests/test_django_setup.py | 11 +++++++++++ 5 files changed, 23 insertions(+) create mode 100644 {{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/tests/__init__.py create mode 100644 {{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/tests/test_django_setup.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 09ed138..648d967 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,3 +50,5 @@ jobs: run: | chmod +x ./src/manage.py pipenv run ./src/manage.py --help + - name: pytest + run: pytest diff --git a/{{ cookiecutter.project_slug }}/Pipfile b/{{ cookiecutter.project_slug }}/Pipfile index 828ee66..67e6588 100644 --- a/{{ cookiecutter.project_slug }}/Pipfile +++ b/{{ cookiecutter.project_slug }}/Pipfile @@ -19,6 +19,8 @@ opentelemetry-exporter-prometheus = "*" # translation of telemet ipython = "*" black = "*" isort = "*" +pytest = "*" +pytest-django = "*" [requires] python_version = "3" diff --git a/{{ cookiecutter.project_slug }}/pyproject.toml b/{{ cookiecutter.project_slug }}/pyproject.toml index e13a6b1..6ebdd73 100644 --- a/{{ cookiecutter.project_slug }}/pyproject.toml +++ b/{{ cookiecutter.project_slug }}/pyproject.toml @@ -3,3 +3,11 @@ line-length = 110 [tool.isort] profile = "black" + +[tool.pytest.ini_options] +pythonpath = "src" +testpaths = "src/{{ cookiecutter.project_slug }}/tests" +log_cli = true +log_cli_level = "info" +django_find_project = false +DJANGO_SETTINGS_MODULE = "{{ cookiecutter.project_slug }}.settings" diff --git a/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/tests/__init__.py b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/tests/test_django_setup.py b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/tests/test_django_setup.py new file mode 100644 index 0000000..6c920b3 --- /dev/null +++ b/{{ cookiecutter.project_slug }}/src/{{ cookiecutter.project_slug }}/core/tests/test_django_setup.py @@ -0,0 +1,11 @@ +from django.shortcuts import resolve_url + + +def test_django_loads(): + from django.conf import settings + assert len(settings.INSTALLED_APPS) > 0 + + +def test_openapi_schema_loads(client): + response = client.get(resolve_url("openapi_schema")) + assert response.status == 200