Skip to content

Commit

Permalink
isolate mandatory env vars in test.py, remove corresponding default v…
Browse files Browse the repository at this point in the history
…alues from base.py
  • Loading branch information
vincentporte committed Dec 19, 2024
1 parent 69bd89d commit fbc6a4b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
18 changes: 8 additions & 10 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,12 @@
# S3 uploads
# ------------------------------------------------------------------------------

AWS_S3_ACCESS_KEY_ID = os.getenv("CELLAR_ADDON_KEY_ID", "123")
AWS_S3_SECRET_ACCESS_KEY = os.getenv("CELLAR_ADDON_KEY_SECRET", "secret")
AWS_S3_ENDPOINT_URL = (
f"{os.getenv('CELLAR_ADDON_PROTOCOL', 'https')}://{os.getenv('CELLAR_ADDON_HOST', 'set-var-env.com')}"
)
AWS_STORAGE_BUCKET_NAME = os.getenv("S3_STORAGE_BUCKET_NAME", "private-bucket")
AWS_STORAGE_BUCKET_NAME_PUBLIC = os.getenv("S3_STORAGE_BUCKET_NAME_PUBLIC", "public-bucket")
AWS_S3_STORAGE_BUCKET_REGION = os.getenv("S3_STORAGE_BUCKET_REGION", "eu-west-3")
AWS_S3_ACCESS_KEY_ID = os.getenv("CELLAR_ADDON_KEY_ID")
AWS_S3_SECRET_ACCESS_KEY = os.getenv("CELLAR_ADDON_KEY_SECRET")
AWS_S3_ENDPOINT_URL = f"{os.getenv('CELLAR_ADDON_PROTOCOL')}://{os.getenv('CELLAR_ADDON_HOST')}"
AWS_STORAGE_BUCKET_NAME = os.getenv("S3_STORAGE_BUCKET_NAME")
AWS_STORAGE_BUCKET_NAME_PUBLIC = os.getenv("S3_STORAGE_BUCKET_NAME_PUBLIC")
AWS_S3_STORAGE_BUCKET_REGION = os.getenv("S3_STORAGE_BUCKET_REGION")

# MEDIA CONFIGURATION
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -359,11 +357,11 @@

# SENDINBLUE
# ---------------------------------------
SIB_URL = os.getenv("SIB_URL", "http://test.com")
SIB_URL = os.getenv("SIB_URL")
SIB_SMTP_ROUTE = "smtp/email"
SIB_CONTACTS_ROUTE = "contacts/import"

SIB_API_KEY = os.getenv("SIB_API_KEY", "set-sib-api-key")
SIB_API_KEY = os.getenv("SIB_API_KEY")
DEFAULT_FROM_EMAIL = os.getenv("DEFAULT_FROM_EMAIL", "[email protected]")

SIB_MAGIC_LINK_TEMPLATE = 31
Expand Down
31 changes: 31 additions & 0 deletions config/settings/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os

from lacommunaute.utils.enums import Environment

from .base import * # pylint: disable=wildcard-import,unused-wildcard-import # noqa: F403 F401


# Django settings
# ---------------
SECRET_KEY = "v3ry_s3cr3t_k3y"

ENVIRONMENT = Environment.TEST

# S3 uploads
# ------------------------------------------------------------------------------

AWS_S3_ACCESS_KEY_ID = os.getenv("CELLAR_ADDON_KEY_ID", "minioadmin")
AWS_S3_SECRET_ACCESS_KEY = os.getenv("CELLAR_ADDON_KEY_SECRET", "minioadmin")
AWS_S3_ENDPOINT_URL = (
f"{os.getenv('CELLAR_ADDON_PROTOCOL', 'http')}://{os.getenv('CELLAR_ADDON_HOST', 'localhost:900')}"
)
AWS_STORAGE_BUCKET_NAME = "private-bucket"
AWS_STORAGE_BUCKET_NAME_PUBLIC = "public-bucket"
AWS_S3_STORAGE_BUCKET_REGION = "eu-west-3"

MEDIA_URL = f"{AWS_S3_ENDPOINT_URL}/"

# SENDINBLUE
# ---------------------------------------
SIB_URL = "http://test.com"
SIB_API_KEY = "dummy-sib-api-key"
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
DJANGO_SETTINGS_MODULE = config.settings.base
DJANGO_SETTINGS_MODULE = config.settings.test
python_files = tests*.py test_*.py
addopts =
--reuse-db
Expand Down

0 comments on commit fbc6a4b

Please sign in to comment.