diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 34a8608..ab1f700 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -74,8 +74,9 @@ jobs: --health-timeout 5s --health-retries 5 - # env: - # TOXENV: pg-only + env: + TOXENV: pg-only + DATABASE_URL: postgres://postgres:postgres@postgres:5432/django_anonymiser steps: - name: Check out the repository @@ -89,4 +90,4 @@ jobs: - name: Install and run tox run: | pip install tox - tox -e pg-only + tox diff --git a/pyproject.toml b/pyproject.toml index b980b3c..bc0cfb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,9 +29,8 @@ packages = [{ include = "anonymiser" }] python = "^3.10" django = "^3.2 || ^4.0 || ^5.0" -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] dj-database-url = "*" -psycopg2-binary = "*" black = "*" coverage = "*" freezegun = "*" @@ -42,6 +41,11 @@ pytest-cov = "*" pytest-django = "*" ruff = "*" tox = "*" +# optional - used for testing with Postgres +psycopg2-binary = { version = "*", optional = true } + +[tool.poetry.extras] +postgres = ["psycopg2-binary"] [build-system] requires = ["poetry>=0.12"] diff --git a/tests/settings_postgres.py b/tests/settings_postgres.py index 329b909..42ab6d4 100644 --- a/tests/settings_postgres.py +++ b/tests/settings_postgres.py @@ -1,13 +1,11 @@ from tests.settings import * # noqa +from os import getenv +import dj_database_url + +DEFAULT_DATABASE_URL = getenv( + "DEFAULT_DATABASE_URL", + "postgres://postgres@localhost:5432/django_anonymiser", +) # NB this is obviously not a secure password, but it's only for testing -DATABASES = { - "default": { - "ENGINE": "django.db.backends.postgresql", - "NAME": "django_anonymiser", - "USER": "postgres", - "PASSWORD": "postgres", - "HOST": "localhost", - "PORT": "5432", - } -} +DATABASES["default"] = dj_database_url.parse(DEFAULT_DATABASE_URL) # noqa: F405 diff --git a/tox.ini b/tox.ini index dfb035b..7dd0546 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,7 @@ commands = [testenv:pg-only] deps = + dj_database_url pytest pytest-django psycopg2-binary