From b269ce81e6b0da7ecdd796c7b8ab849531547e5b Mon Sep 17 00:00:00 2001 From: Carlos Quintana <74399022+cquintana92@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:46:48 +0200 Subject: [PATCH] fix: missing branch on get_alias_recipient_name (#2254) * fix: missing branch on get_alias_recipient_name * test: add test for missing else branch --- app/alias_utils.py | 3 +-- tests/test_alias_utils.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/alias_utils.py b/app/alias_utils.py index f8a9e197..47851f8b 100644 --- a/app/alias_utils.py +++ b/app/alias_utils.py @@ -569,5 +569,4 @@ def get_alias_recipient_name(alias: Alias) -> AliasRecipientName: name=sl_formataddr((alias.custom_domain.name, alias.email)), message=f"Put domain default alias name {alias.custom_domain.name} in from header", ) - else: - return AliasRecipientName(name=alias.email) + return AliasRecipientName(name=alias.email) diff --git a/tests/test_alias_utils.py b/tests/test_alias_utils.py index 23839c3a..507b507a 100644 --- a/tests/test_alias_utils.py +++ b/tests/test_alias_utils.py @@ -184,6 +184,25 @@ def test_get_alias_recipient_alias_with_name_and_custom_domain_name(): assert res.name == f"{alias.name} <{alias.email}>" +def test_get_alias_recipient_alias_without_name_and_custom_domain_without_name(): + user = create_new_user() + custom_domain = CustomDomain.create( + user_id=user.id, + domain=random_domain(), + verified=True, + ) + alias = Alias.create( + user_id=user.id, + email=random_email(), + mailbox_id=user.default_mailbox_id, + custom_domain_id=custom_domain.id, + commit=True, + ) + res = get_alias_recipient_name(alias) + assert res.message is None + assert res.name == alias.email + + def test_get_alias_recipient_alias_without_name_and_custom_domain_name(): user = create_new_user() custom_domain = CustomDomain.create(