Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions config.py → myproj/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
from typing import Optional

from pydantic import BaseSettings

Expand All @@ -18,9 +17,7 @@ class Settings(BaseSettings):
DEBUG: bool = True

class Config:
env_prefix = (
os.getenv("NAMESPACE", "DEV").upper() + "_"
) # defaults to 'APP_'
env_prefix = os.getenv("NAMESPACE", "DEV").upper() + "_"


settings = Settings()
19 changes: 19 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
from importlib import reload

from asynctest import TestCase, mock

from myproj import config


class ConfigTest(TestCase):
async def test_debug_is_false(self):
with mock.patch.dict(os.environ, DEV_DEBUG="0"):
s = config.Settings()
self.assertEqual(s.DEBUG, False)

async def test_other_namespace(self):
with mock.patch.dict(os.environ, NAMESPACE="PROD", PROD_DEBUG="0"):
reload(config)
s = config.Settings()
self.assertEqual(s.DEBUG, False)