diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 7d23e8b6..83778423 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,4 +1,4 @@ -name: test_Django +name: Testing Django on: [ pull_request, push ] # activates the workflow when there is a push or pull request in the repo jobs: test_project: @@ -9,9 +9,7 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install django==5.0.2 - pip install django-extensions - pip install ruff + pip install -r requirements-test.txt - name: Run linting tools run: | cd app/ @@ -20,5 +18,5 @@ jobs: run: | cp .env.testing app/.env cd app/ - ls -al + mkdir static_files python manage.py test diff --git a/app/app/settings.py b/app/app/settings.py index b5266866..bba54394 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -11,11 +11,17 @@ """ import os +import sys from pathlib import Path +import environ + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent +# Take environment variables from .env file +environ.Env.read_env(os.path.join(BASE_DIR, ".env")) + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ @@ -96,6 +102,9 @@ } } +if "test" in sys.argv or "test_coverage" in sys.argv: # Covers regular testing and django-coverage + DATABASES["default"]["ENGINE"] = "django.db.backends.sqlite3" + # Password validation # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 00000000..e00d50bd --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,3 @@ +-r requirements.txt +django-extensions +ruff diff --git a/requirements.txt b/requirements.txt index 62e806c8..cf164c91 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ django==5.0.2 psycopg2-binary gunicorn whitenoise +django-environ