summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/test.yml18
-rw-r--r--takahe/settings.py17
2 files changed, 26 insertions, 9 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 5122986..9201f4c 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -10,10 +10,19 @@ on:
jobs:
test:
+ name: test py${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
+ db:
+ - "postgres://postgres:postgres@localhost/postgres"
+ - "sqlite:///takahe.db"
+ include:
+ - db: "sqlite:///takahe.db"
+ search: false
+ - db: "postgres://postgres:postgres@localhost/postgres"
+ search: true
services:
postgres:
image: postgres:15
@@ -22,7 +31,11 @@ jobs:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports: ["5432:5432"]
- options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
@@ -35,7 +48,8 @@ jobs:
python -m pip install -r requirements-dev.txt
- name: Run pytest
env:
- TAKAHE_DATABASE_SERVER: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres"
+ TAKAHE_DATABASE_SERVER: ${{ matrix.db }}
+ TAKAHE_SEARCH: ${{ matrix.search }}
TAKAHE_ENVIRONMENT: "test"
TAKAHE_SECRET_KEY: "testing_secret"
TAKAHE_MAIN_DOMAIN: "example.com"
diff --git a/takahe/settings.py b/takahe/settings.py
index 288ecca..788654d 100644
--- a/takahe/settings.py
+++ b/takahe/settings.py
@@ -7,12 +7,16 @@ from typing import List, Literal, Optional, Union
import dj_database_url
import sentry_sdk
-from pydantic import AnyUrl, BaseSettings, EmailStr, Field, PostgresDsn, validator
+from pydantic import AnyUrl, BaseSettings, EmailStr, Field, validator
from sentry_sdk.integrations.django import DjangoIntegration
BASE_DIR = Path(__file__).resolve().parent.parent
+class ImplicitHostname(AnyUrl):
+ host_required = False
+
+
class MediaBackendUrl(AnyUrl):
host_required = False
allowed_schemes = {"s3", "gcs", "local"}
@@ -35,11 +39,6 @@ TAKAHE_ENV_FILE = os.environ.get(
)
-TAKAHE_ENV_FILE = os.environ.get(
- "TAKAHE_ENV_FILE", "test.env" if "pytest" in sys.modules else ".env"
-)
-
-
class Settings(BaseSettings):
"""
Pydantic-powered settings, to provide consistent error messages, strong
@@ -47,7 +46,7 @@ class Settings(BaseSettings):
"""
#: The default database.
- DATABASE_SERVER: Optional[PostgresDsn]
+ DATABASE_SERVER: Optional[ImplicitHostname]
#: The currently running environment, used for things such as sentry
#: error reporting.
@@ -91,6 +90,10 @@ class Settings(BaseSettings):
MEDIA_ROOT: str = str(BASE_DIR / "media")
MEDIA_BACKEND: Optional[MediaBackendUrl] = None
+ #: If search features like full text search should be enabled.
+ #: (placeholder setting, no effect)
+ SEARCH: bool = True
+
PGHOST: Optional[str] = None
PGPORT: Optional[int] = 5432
PGNAME: str = "takahe"