fix: missing branch on get_alias_recipient_name (#2254)

* fix: missing branch on get_alias_recipient_name

* test: add test for missing else branch
This commit is contained in:
Carlos Quintana 2024-10-09 10:46:48 +02:00 committed by GitHub
parent 5bc72f92d4
commit b269ce81e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -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)

View file

@ -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(