diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..73d8e64 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,10 @@ +[run] +omit = + */migrations/* + */admin.py + */tests/* + */urls.py + */apps.py + la_chariotte/settings.py + la_chariotte/asgi.py + la_chariotte/wsgi.py diff --git a/la_chariotte/settings.py b/la_chariotte/settings.py index 9de6adb..159b46b 100644 --- a/la_chariotte/settings.py +++ b/la_chariotte/settings.py @@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/4.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/4.1/ref/settings/ """ - +import os from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -77,14 +77,18 @@ WSGI_APPLICATION = "la_chariotte.wsgi.application" DATABASES = { "default": { "ENGINE": "django.db.backends.postgresql", - "NAME": "chariotte-db", - "USER": "laetitia", - "PASSWORD": "toto", - "HOST": "127.0.0.1", - "PORT": "5432", + "NAME": os.getenv("DB_NAME", "chariotte-db"), } } +if os.getenv("DB_USER"): + DATABASES["default"]["USER"] = os.getenv("DB_USER") +if os.getenv("DB_PASSWORD"): + DATABASES["default"]["PASSWORD"] = os.getenv("DB_PASSWORD") +if os.getenv("DB_HOST"): + DATABASES["default"]["HOST"] = os.getenv("DB_HOST") +if os.getenv("DB_PORT"): + DATABASES["default"]["PORT"] = os.getenv("DB_PORT") # Password validation # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators diff --git a/pyproject.toml b/pyproject.toml index 51ef109..37f8bb5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ version = "0.0.1" description = "Web application for organising grouped orders" readme = "readMe.md" license = {file = "LICENSE"} +authors = [{name = "Hashbang", email = "support@hashbang.fr"}] dependencies = [ "django>=4,<5", "psycopg2>=2,<3", @@ -22,11 +23,14 @@ dev = [ "pip-tools>=6,<7", "pytest-isort>=3,<4", "pytest-django>=4,<5", + "pytest-cov>=4,<5", + "diff-cover>=4,<5", + "pytest-black<1", ] [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "la_chariotte.settings" -addopts = "--isort" +addopts = "--isort --black --reuse-db --cov-report xml --cov-report term-missing --cov=la_chariotte -p no:warnings" isort_ignore = ["*migrations/*.py"] [tool.isort] diff --git a/readMe.md b/readMe.md index 7d49e43..b0e366f 100644 --- a/readMe.md +++ b/readMe.md @@ -15,13 +15,17 @@ Si il y a des erreurs ISORT, on peut lancer isort pour trier les fichiers : isort . ``` -Vérifier le formatage des fichers avec flake8 : +Si il y a des erreurs BLACK, on peut lancer black pour linter le code : +```bash +black . +``` +Vérifier le formatage des fichers avec flake8 : ```bash flake8 ``` -Si l'erreur `BLK100 Blakck would make changes.` apparait, on peut lancer black pour formater les fichiers : +Si l'erreur `BLK100 Black would make changes.` apparait, on peut lancer black pour formater les fichiers : ```bash black .