Skip to content

Commit

Permalink
Merge branch 'main' into normalize_package
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarons authored Sep 24, 2023
2 parents 7aaf44a + 2a0b4a5 commit 03102e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def send(config, last_send=None, dry_run=False):
else:
smtp.login(email, password)

msg = build_message(email)
msg = build_message(email, to_email)

smtp.sendmail(from_addr=email, to_addrs=to_email, msg=msg.as_string())
smtp.quit()
Expand All @@ -49,9 +49,9 @@ def send(config, last_send=None, dry_run=False):
return sent_on


def build_message(email):
def build_message(email, to_email):
"""Create email message."""
message = Message(to=email)
message = Message(to=to_email)
message.sender = "icloud-docker <" + email + ">"
message.date = datetime.datetime.now().strftime("%d/%m/%Y %H:%M")
message.subject = "icloud-docker: Two step authentication required"
Expand Down
8 changes: 6 additions & 2 deletions tests/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def setUp(self) -> None:
"app": {
"smtp": {
"email": "[email protected]",
"to": "[email protected]",
"host": "smtp.test.com",
"port": "587",
"password": "password",
Expand Down Expand Up @@ -44,8 +45,11 @@ def test_dry_run_send(self):

def test_build_message(self):
"""Test for building a valid email."""
msg = notify.build_message(self.config["app"]["smtp"]["email"])
self.assertEqual(msg.to, self.config["app"]["smtp"]["email"])
msg = notify.build_message(
email=self.config["app"]["smtp"]["email"],
to_email=self.config["app"]["smtp"]["to"],
)
self.assertEqual(msg.to, self.config["app"]["smtp"]["to"])
self.assertIn(self.config["app"]["smtp"]["email"], msg.sender)
self.assertIn("icloud-docker: Two step authentication required", msg.subject)
self.assertIn(
Expand Down

0 comments on commit 03102e3

Please sign in to comment.