Skip to content

Commit

Permalink
[fix] mail_outbound_static fix pre-commit errore
Browse files Browse the repository at this point in the history
  • Loading branch information
matteoopenf committed Jan 29, 2025
1 parent cc96dc2 commit 48dc81b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions mail_outbound_static/tests/test_ir_mail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_send_email_injects_from_with_canonical(self):
proper handling in the split.
"""
user = "Test < User"
self.message.replace_header("From", "%s <[email protected]>" % user)
self.message.replace_header("From", f"{user} <[email protected]>")
bounce_parameter = self.parameter_model.search(
[("key", "=", "mail.bounce.alias")]
)
Expand All @@ -145,7 +145,7 @@ def test_send_email_injects_from_with_canonical(self):
def test_01_from_outgoing_server_domainone(self):
self._init_mail_server_domain_whilelist_based()
domain = "domainone.com"
email_from = "Mitchell Admin <admin@%s>" % domain
email_from = f"Mitchell Admin <admin@{domain}>"
expected_mail_server = self.mail_server_domainone

self.message.replace_header("From", email_from)
Expand All @@ -168,7 +168,7 @@ def test_01_from_outgoing_server_domainone(self):
def test_02_from_outgoing_server_domaintwo(self):
self._init_mail_server_domain_whilelist_based()
domain = "domaintwo.com"
email_from = "Mitchell Admin <admin@%s>" % domain
email_from = f"Mitchell Admin <admin@{domain}>"
expected_mail_server = self.mail_server_domaintwo

self.message.replace_header("From", email_from)
Expand All @@ -191,15 +191,15 @@ def test_02_from_outgoing_server_domaintwo(self):
def test_03_from_outgoing_server_another(self):
self._init_mail_server_domain_whilelist_based()
domain = "example.com"
email_from = "Mitchell Admin <admin@%s>" % domain
email_from = f"Mitchell Admin <admin@{domain}>"
expected_mail_server = self.mail_server_domainone

self.message.replace_header("From", email_from)
# A mail server is configured for the email
with self.mock_smtplib_connection():
message = self._send_mail(self.message)
self.assertEqual(
message["From"], "Mitchell Admin <%s>" % expected_mail_server.smtp_from
message["From"], f"Mitchell Admin {expected_mail_server.smtp_from}"
)

used_mail_server = self.IrMailServer._get_mail_sever(domain)
Expand All @@ -216,7 +216,7 @@ def test_03_from_outgoing_server_another(self):
def test_04_from_outgoing_server_none_use_config(self):
self._init_mail_server_domain_whilelist_based()
domain = "example.com"
email_from = "Mitchell Admin <admin@%s>" % domain
email_from = f"Mitchell Admin <admin@{domain}>"

self._delete_mail_servers()
self.assertFalse(self.IrMailServer.search([]))
Expand All @@ -233,12 +233,12 @@ def test_04_from_outgoing_server_none_use_config(self):
# A mail server is configured for the email
with self.mock_smtplib_connection():
message = self._send_mail(self.message)
self.assertEqual(message["From"], "Mitchell Admin <%s>" % config_smtp_from)
self.assertEqual(message["From"], f"Mitchell Admin {config_smtp_from}")

used_mail_server = self.IrMailServer._get_mail_sever("example.com")
used_mail_server = self.IrMailServer.browse(used_mail_server)
self.assertFalse(
used_mail_server, "using this mail server %s" % (used_mail_server.name)
used_mail_server, f"using this mail server {used_mail_server.name}"
)

def test_05_from_outgoing_server_none_same_domain(self):
Expand All @@ -255,7 +255,7 @@ def test_05_from_outgoing_server_none_same_domain(self):
" or smtp_domain_whitelist."
)

email_from = "Mitchell Admin <admin@%s>" % domain
email_from = f"Mitchell Admin <admin@{domain}>"

self._delete_mail_servers()
self.assertFalse(self.IrMailServer.search([]))
Expand All @@ -272,7 +272,7 @@ def test_05_from_outgoing_server_none_same_domain(self):
def test_06_from_outgoing_server_no_name_from(self):
self._init_mail_server_domain_whilelist_based()
domain = "example.com"
email_from = "test@%s" % domain
email_from = f"test@{domain}"
expected_mail_server = self.mail_server_domainone

self.message.replace_header("From", email_from)
Expand All @@ -295,7 +295,7 @@ def test_06_from_outgoing_server_no_name_from(self):
def test_07_from_outgoing_server_multidomain_1(self):
self._init_mail_server_domain_whilelist_based()
domain = "domainthree.com"
email_from = "Mitchell Admin <admin@%s>" % domain
email_from = f"Mitchell Admin <admin@{domain}>"
expected_mail_server = self.mail_server_domainthree

self.message.replace_header("From", email_from)
Expand All @@ -318,7 +318,7 @@ def test_07_from_outgoing_server_multidomain_1(self):
def test_08_from_outgoing_server_multidomain_3(self):
self._init_mail_server_domain_whilelist_based()
domain = "domainmulti.com"
email_from = "test@%s" % domain
email_from = f"test@{domain}"
expected_mail_server = self.mail_server_domainthree

self.message.replace_header("From", email_from)
Expand Down

0 comments on commit 48dc81b

Please sign in to comment.