set_app_config¶
Scope: function | Returns: callable
The set_app_config fixture returns a callable that replaces the application configuration for a given application. To supply configuration for all tests in a module by overriding a fixture instead, see lime_db_app_config.
Signature¶
set_app_config(
lime_app: str | LimeApplication | None = None,
config: dict | AppConfig | None = None,
app_id: str | None = None,
) -> None
Either lime_app or app_id must be provided, otherwise a RuntimeError is raised.
When config is a dict, it must use the following structure:
Basic usage¶
def test_something(lime_app, set_app_config):
set_app_config(
lime_app,
config={
"config": {"integration_url": "https://example.com"},
"secrets": {"api_key": "test-secret"},
},
)
Multiple calls¶
Each call is a full replacement — the previous config is cleared before the new values are applied. When using lime_app or other lime_app_* fixtures, the change is reflected in LimeApplication.config:
def test_config_is_replaced(lime_app, set_app_config):
set_app_config(lime_app, config={"config": {"key": "first"}})
assert lime_app.config.key == "first"
set_app_config(lime_app, config={"config": {"key": "second"}})
assert lime_app.config.key == "second"
Using AppConfig¶
Pass an AppConfig object instead of a dict: