forked from Github-Mirrors/canaille
tests: avoid producing test artifacts in the repository
This commit is contained in:
parent
4a717fa714
commit
7e01008ac0
1 changed files with 6 additions and 4 deletions
|
@ -40,21 +40,23 @@ def test_configuration_nestedsecrets_directory(tmp_path, backend, configuration)
|
||||||
del os.environ["SECRETS_DIR"]
|
del os.environ["SECRETS_DIR"]
|
||||||
|
|
||||||
|
|
||||||
def test_configuration_from_environment_vars():
|
def test_configuration_from_environment_vars(tmp_path):
|
||||||
"""Canaille should read configuration from environment vars."""
|
"""Canaille should read configuration from environment vars."""
|
||||||
os.environ["SECRET_KEY"] = "very-very-secret"
|
os.environ["SECRET_KEY"] = "very-very-secret"
|
||||||
os.environ["CANAILLE__SMTP__FROM_ADDR"] = "user@mydomain.test"
|
os.environ["CANAILLE__SMTP__FROM_ADDR"] = "user@mydomain.test"
|
||||||
os.environ["CANAILLE_SQL__DATABASE_URI"] = "sqlite:///anything.db"
|
os.environ["CANAILLE_SQL__DATABASE_URI"] = f"sqlite://{tmp_path}/anything.db"
|
||||||
|
|
||||||
conf = settings_factory({"TIMEZONE": "UTC"})
|
conf = settings_factory({"TIMEZONE": "UTC"})
|
||||||
assert conf.SECRET_KEY == "very-very-secret"
|
assert conf.SECRET_KEY == "very-very-secret"
|
||||||
assert conf.CANAILLE.SMTP.FROM_ADDR == "user@mydomain.test"
|
assert conf.CANAILLE.SMTP.FROM_ADDR == "user@mydomain.test"
|
||||||
assert conf.CANAILLE_SQL.DATABASE_URI == "sqlite:///anything.db"
|
assert conf.CANAILLE_SQL.DATABASE_URI == f"sqlite://{tmp_path}/anything.db"
|
||||||
|
|
||||||
app = create_app({"TIMEZONE": "UTC"})
|
app = create_app({"TIMEZONE": "UTC"})
|
||||||
assert app.config["SECRET_KEY"] == "very-very-secret"
|
assert app.config["SECRET_KEY"] == "very-very-secret"
|
||||||
assert app.config["CANAILLE"]["SMTP"]["FROM_ADDR"] == "user@mydomain.test"
|
assert app.config["CANAILLE"]["SMTP"]["FROM_ADDR"] == "user@mydomain.test"
|
||||||
assert app.config["CANAILLE_SQL"]["DATABASE_URI"] == "sqlite:///anything.db"
|
assert (
|
||||||
|
app.config["CANAILLE_SQL"]["DATABASE_URI"] == f"sqlite://{tmp_path}/anything.db"
|
||||||
|
)
|
||||||
|
|
||||||
del os.environ["SECRET_KEY"]
|
del os.environ["SECRET_KEY"]
|
||||||
del os.environ["CANAILLE__SMTP__FROM_ADDR"]
|
del os.environ["CANAILLE__SMTP__FROM_ADDR"]
|
||||||
|
|
Loading…
Reference in a new issue