-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #4
- Loading branch information
hudaifasaleh
committed
Jun 30, 2023
1 parent
4c6092f
commit 75e6f8a
Showing
7 changed files
with
55 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from django.core import mail | ||
from django_extensions.management.jobs import DailyJob | ||
|
||
from dailyInbox.accounts.models import Account | ||
|
||
|
||
class Job(DailyJob): | ||
help = "Send mail to active accounts" | ||
|
||
def execute(self): | ||
accounts = Account.objects.active() | ||
for account in accounts: | ||
mail.send_mail(subject="Replace this subject", | ||
message="Replace this message", | ||
html_message="Replace this html message", | ||
from_email="Who is this from email", | ||
recipient_list=[account.user.email], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
from dailyInbox.entries.jobs import SendMailJob | ||
from dailyInbox.accounts.tests.factories import UserFactory | ||
from dailyInbox.entries.jobs.send_mail import Job as SendMailJob | ||
|
||
|
||
class TestMailJob: | ||
def test_send_email(self): | ||
class TestSendMailJob: | ||
def test_send_email(self, mailoutbox): | ||
"""An active account receive an email prompt""" | ||
user = UserFactory() | ||
job = SendMailJob() | ||
job.execute() | ||
assert len(mailoutbox) == 1 | ||
mail = mailoutbox[0] | ||
assert mail.to == [user.email] | ||
|
||
# TODO: assert subject | ||
# TODO: assert message | ||
# TODO: assert html_message | ||
# TODO: assert from_email |