From a1a369df30250d6be99ce626fb07ff7c49ed3176 Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Mon, 29 Apr 2024 14:02:20 +0200 Subject: [PATCH] checking enviroment files testing cat fixed cat command testing tests testing location testing django-environ fixed install added new install added test requiment file updated requirement file fixed dir testing sqlight tests added make dir cleaned up code --- .github/workflows/testing.yml | 8 +++----- app/app/settings.py | 9 +++++++++ requirements-test.txt | 3 +++ requirements.txt | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 requirements-test.txt 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