From e6833a2d52849e01dfeb3fe4a88093678fd88d93 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 26 Dec 2021 12:31:12 +0800 Subject: [PATCH 1/2] Allow running tests using sqlite --- tests/settings.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tests/settings.py b/tests/settings.py index 4ead5429..83946b38 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -4,16 +4,25 @@ 'model_utils', 'tests', ) -DATABASES = { - "default": { - "ENGINE": "django.db.backends.postgresql_psycopg2", - "NAME": os.environ.get("DB_NAME", "modelutils"), - "USER": os.environ.get("DB_USER", 'postgres'), - "PASSWORD": os.environ.get("DB_PASSWORD", ""), - "HOST": os.environ.get("DB_HOST", "localhost"), - "PORT": os.environ.get("DB_PORT", 5432) - }, -} + +if os.environ.get('SQLITE'): + DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + }, + } +else: + DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql_psycopg2", + "NAME": os.environ.get("DB_NAME", "modelutils"), + "USER": os.environ.get("DB_USER", 'postgres'), + "PASSWORD": os.environ.get("DB_PASSWORD", ""), + "HOST": os.environ.get("DB_HOST", "localhost"), + "PORT": os.environ.get("DB_PORT", 5432) + }, + } + SECRET_KEY = 'dummy' CACHES = { From 70963149d4996ab4e274f74339d025fa44cfe029 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 26 Dec 2021 13:49:49 +0800 Subject: [PATCH 2/2] tests.settings: Update backend path --- tests/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/settings.py b/tests/settings.py index 83946b38..c8ec92a9 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -14,7 +14,7 @@ else: DATABASES = { "default": { - "ENGINE": "django.db.backends.postgresql_psycopg2", + "ENGINE": "django.db.backends.postgresql", "NAME": os.environ.get("DB_NAME", "modelutils"), "USER": os.environ.get("DB_USER", 'postgres'), "PASSWORD": os.environ.get("DB_PASSWORD", ""),