summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-27 00:32:18 -0700
committerAndrew Godwin2022-11-27 00:32:34 -0700
commit43771601550577beca38db88643128972ece1925 (patch)
tree8bb97bfe4d45878da20d9cff3233a2a06e293325
parent93aaf119c5e359053620a894dfd0ab03030e1f44 (diff)
downloadtakahe-43771601550577beca38db88643128972ece1925.tar.gz
takahe-43771601550577beca38db88643128972ece1925.tar.bz2
takahe-43771601550577beca38db88643128972ece1925.zip
Force testing settings during test
-rw-r--r--takahe/settings.py3
-rw-r--r--test.env8
2 files changed, 10 insertions, 1 deletions
diff --git a/takahe/settings.py b/takahe/settings.py
index bc55711..142c690 100644
--- a/takahe/settings.py
+++ b/takahe/settings.py
@@ -1,4 +1,5 @@
import secrets
+import sys
import urllib.parse
from pathlib import Path
from typing import List, Literal, Optional, Union
@@ -105,7 +106,7 @@ class Settings(BaseSettings):
}
-SETUP = Settings()
+SETUP = Settings(_env_file="test.env" if "pytest" in sys.modules else None)
SECRET_KEY = SETUP.SECRET_KEY
DEBUG = SETUP.DEBUG
diff --git a/test.env b/test.env
new file mode 100644
index 0000000..deeee3a
--- /dev/null
+++ b/test.env
@@ -0,0 +1,8 @@
+TAKAHE_DATABASE_SERVER="postgres://postgres@localhost/takahe"
+TAKAHE_DEBUG=true
+TAKAHE_SECRET_KEY="insecure_secret"
+TAKAHE_CSRF_TRUSTED_ORIGINS=["http://127.0.0.1:8000", "https://127.0.0.1:8000"]
+TAKAHE_USE_PROXY_HEADERS=true
+TAKAHE_EMAIL_SERVER="console://console"
+TAKAHE_MAIN_DOMAIN="example.com"
+TAKAHE_ENVIRONMENT="development"