Skip to content

Commit

Permalink
SCKAN-287 - Add TESTING environment configuration for database settings
Browse files Browse the repository at this point in the history
  • Loading branch information
D-GopalKrishna committed Jan 2, 2025
1 parent 297e3d4 commit bd41197
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
PRODUCTION = os.environ.get("PRODUCTION", "False").lower() in ("true", "1")
USE_PG = os.environ.get("USE_PG", "False").lower() in ("true", "1")
TESTING = os.environ.get("TESTING", "False").lower() in ("true", "1")
DEBUG = os.environ.get("DEBUG", str(not PRODUCTION)).lower() in ("true", "1")

ALLOWED_HOSTS = [
Expand Down Expand Up @@ -106,7 +107,14 @@

# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
if PRODUCTION or USE_PG:
if TESTING:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "persistent", "test_db.sqlite3"),
}
}
elif PRODUCTION or USE_PG:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
Expand Down

0 comments on commit bd41197

Please sign in to comment.