2022-12-16 21:14:46 +00:00
|
|
|
import os
|
|
|
|
|
2022-12-16 21:33:09 +00:00
|
|
|
import toml
|
2024-03-15 18:58:06 +00:00
|
|
|
|
2022-12-16 21:14:46 +00:00
|
|
|
from canaille import create_app
|
2023-04-09 13:52:55 +00:00
|
|
|
from canaille.app.flask import set_parameter_in_url_query
|
2022-12-11 21:49:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_set_parameter_in_url_query():
|
|
|
|
assert (
|
2024-11-20 22:30:44 +00:00
|
|
|
set_parameter_in_url_query("https://auth.mydomain.test", foo="bar")
|
|
|
|
== "https://auth.mydomain.test?foo=bar"
|
2022-12-11 21:49:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
2024-11-20 22:30:44 +00:00
|
|
|
set_parameter_in_url_query("https://auth.mydomain.test?foo=baz", foo="bar")
|
|
|
|
== "https://auth.mydomain.test?foo=bar"
|
2022-12-11 21:49:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
assert (
|
2024-11-20 22:30:44 +00:00
|
|
|
set_parameter_in_url_query("https://auth.mydomain.test?foo=baz", hello="world")
|
|
|
|
== "https://auth.mydomain.test?foo=baz&hello=world"
|
2022-12-11 21:49:32 +00:00
|
|
|
)
|
2022-12-16 21:14:46 +00:00
|
|
|
|
|
|
|
|
2023-04-10 21:08:09 +00:00
|
|
|
def test_environment_configuration(configuration, tmp_path):
|
2022-12-16 21:33:09 +00:00
|
|
|
config_path = os.path.join(tmp_path, "config.toml")
|
|
|
|
with open(config_path, "w") as fd:
|
|
|
|
toml.dump(configuration, fd)
|
|
|
|
|
|
|
|
os.environ["CONFIG"] = config_path
|
|
|
|
app = create_app()
|
2024-11-20 22:30:44 +00:00
|
|
|
assert app.config["CANAILLE"]["SMTP"]["FROM_ADDR"] == "admin@mydomain.test"
|
2022-12-16 21:33:09 +00:00
|
|
|
|
|
|
|
del os.environ["CONFIG"]
|
|
|
|
os.remove(config_path)
|