diff --git a/src/settings.py b/src/settings.py index e765afa..fd68720 100644 --- a/src/settings.py +++ b/src/settings.py @@ -2,13 +2,14 @@ from functools import lru_cache - -from pydantic import Extra +from pydantic import ConfigDict from pydantic_settings import BaseSettings class Settings(BaseSettings): """Loads settings from .env file""" + model_config = ConfigDict(extra='allow') + UPLOAD_FOLDER: str = 'static' # Should be defined in a .env file @@ -25,13 +26,8 @@ class Settings(BaseSettings): GIELLADETECT_LANGS: str = "" CUSTOM_PATH: str = "" - class Config: - """Specify name of settings file""" - env_file = '.env' - extra = Extra.allow - -settings = Settings() +settings = Settings(_env_file='.env') @lru_cache() diff --git a/test/test_settings.py b/test/test_settings.py new file mode 100644 index 0000000..063c131 --- /dev/null +++ b/test/test_settings.py @@ -0,0 +1,20 @@ +"""Test that settings are loaded correctly""" + +from src.settings import Settings + + +def test_config(): + settings = Settings(_env_file='.env.example') + """Test that settings are loaded correctly""" + assert settings.MOUNT_FOLDER == "/tmp/pdf_dir" + assert settings.MAX_FILE_SIZE_MB == 123 + assert settings.ENVIRONMENT == "local" + assert settings.LANGUAGES == "mul,eng,nob" + assert settings.REGISTRY_FILE == "" + assert settings.REGISTRY_HOST == "" + assert settings.REGISTRY_USER == "" + assert settings.REGISTRY_DATABASE == "" + assert settings.REGISTRY_PASSWORD == "" + assert settings.USE_GIELLADETECT is False + assert settings.GIELLADETECT_LANGS == "" + assert settings.CUSTOM_PATH == ""