From b16630063b4b390058046b1e9825445778a1c87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Sun, 12 May 2024 10:42:41 +0200 Subject: [PATCH] fix: check command when SMTP configuration is not defined --- canaille/app/configuration.py | 3 ++- tests/app/commands/test_check.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/canaille/app/configuration.py b/canaille/app/configuration.py index a5072799..bddee471 100644 --- a/canaille/app/configuration.py +++ b/canaille/app/configuration.py @@ -163,7 +163,8 @@ def validate(config, validate_remote=False): from canaille.backends import Backend Backend.instance.validate(config) - validate_smtp_configuration(config["CANAILLE"]["SMTP"]) + if smtp_config := config["CANAILLE"]["SMTP"]: + validate_smtp_configuration(smtp_config) def validate_keypair(config): diff --git a/tests/app/commands/test_check.py b/tests/app/commands/test_check.py index 05d79873..5163580f 100644 --- a/tests/app/commands/test_check.py +++ b/tests/app/commands/test_check.py @@ -12,3 +12,10 @@ def test_check_command_fail(testclient): runner = testclient.app.test_cli_runner() res = runner.invoke(cli, ["check"]) assert res.exit_code == 1, res.stdout + + +def test_check_command_no_smtp(testclient): + testclient.app.config["CANAILLE"]["SMTP"] = None + runner = testclient.app.test_cli_runner() + res = runner.invoke(cli, ["check"]) + assert res.exit_code == 0, res.stdout