chore: use singular style in config class name (#5489)
This commit is contained in:
@@ -3,7 +3,7 @@ from textwrap import dedent
|
||||
import pytest
|
||||
from flask import Flask
|
||||
|
||||
from configs.app_configs import DifyConfigs
|
||||
from configs.app_config import DifyConfig
|
||||
|
||||
EXAMPLE_ENV_FILENAME = '.env'
|
||||
|
||||
@@ -19,32 +19,32 @@ def example_env_file(tmp_path, monkeypatch) -> str:
|
||||
return str(file_path)
|
||||
|
||||
|
||||
def test_dify_configs_undefined_entry(example_env_file):
|
||||
def test_dify_config_undefined_entry(example_env_file):
|
||||
# load dotenv file with pydantic-settings
|
||||
settings = DifyConfigs(_env_file=example_env_file)
|
||||
config = DifyConfig(_env_file=example_env_file)
|
||||
|
||||
# entries not defined in app settings
|
||||
with pytest.raises(TypeError):
|
||||
# TypeError: 'AppSettings' object is not subscriptable
|
||||
assert settings['LOG_LEVEL'] == 'INFO'
|
||||
assert config['LOG_LEVEL'] == 'INFO'
|
||||
|
||||
|
||||
def test_dify_configs(example_env_file):
|
||||
def test_dify_config(example_env_file):
|
||||
# load dotenv file with pydantic-settings
|
||||
settings = DifyConfigs(_env_file=example_env_file)
|
||||
config = DifyConfig(_env_file=example_env_file)
|
||||
|
||||
# constant values
|
||||
assert settings.COMMIT_SHA == ''
|
||||
assert config.COMMIT_SHA == ''
|
||||
|
||||
# default values
|
||||
assert settings.EDITION == 'SELF_HOSTED'
|
||||
assert settings.API_COMPRESSION_ENABLED is False
|
||||
assert settings.SENTRY_TRACES_SAMPLE_RATE == 1.0
|
||||
assert config.EDITION == 'SELF_HOSTED'
|
||||
assert config.API_COMPRESSION_ENABLED is False
|
||||
assert config.SENTRY_TRACES_SAMPLE_RATE == 1.0
|
||||
|
||||
|
||||
def test_flask_configs(example_env_file):
|
||||
flask_app = Flask('app')
|
||||
flask_app.config.from_mapping(DifyConfigs(_env_file=example_env_file).model_dump())
|
||||
flask_app.config.from_mapping(DifyConfig(_env_file=example_env_file).model_dump())
|
||||
config = flask_app.config
|
||||
|
||||
# configs read from dotenv directly
|
Reference in New Issue
Block a user