From 0044fb2c72491302aec7fe6b1192c67f9b5ee9c0 Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Mon, 29 Apr 2024 13:30:23 +0200 Subject: [PATCH] testing dir change added linting tools added dev requirement file updated install testing tests added cp of .env file 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 --- .env.testing | 11 +++++++++++ .github/workflows/testing.yml | 14 ++++++++++---- app/app/settings.py | 9 +++++++++ requirements-test.txt | 3 +++ requirements.txt | 1 + 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 .env.testing create mode 100644 requirements-test.txt diff --git a/.env.testing b/.env.testing new file mode 100644 index 00000000..bfcf91b6 --- /dev/null +++ b/.env.testing @@ -0,0 +1,11 @@ +SECRET_KEY='django-insecure-w!h85bp^$$e8gm%c23r!0%9i7yzd=6w$$s&ic+6!%306&kj8@k*5' +DEBUG=True +DB_HOST=db +DB_PORT=5432 +DB_NAME=term_db +DB_USER=sadilar +DB_PASSWORD=sadilar +LOGGING_FILE=logs/debug.log +LOGGING_HANDLERS_LEVEL=INFO +LOGGING_LOGGERS_LEVEL=INFO +LOGGING_LOGGERS_DJANGO_LEVEL=INFO diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 0418a620..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,8 +9,14 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt + pip install -r requirements-test.txt + - name: Run linting tools + run: | + cd app/ + ruff format . - name: Run Tests run: | - ls -al -# python manage.py test + cp .env.testing app/.env + cd app/ + 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