offloaded some apps.lyric.views responsibilities to new Celery depend fn in .tasks; core.celery created for celery config; CELERY_BROKER_URL added to .settings & throughout project; some lyric view IT responsibility now accordingly covered by task UT domain
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
16
src/apps/lyric/tests/unit/test_tasks.py
Normal file
16
src/apps/lyric/tests/unit/test_tasks.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from django.test import SimpleTestCase
|
||||
from unittest import mock
|
||||
|
||||
from apps.lyric.tasks import send_login_email_task
|
||||
|
||||
|
||||
class SendLoginEmailTaskTest(SimpleTestCase):
|
||||
@mock.patch("apps.lyric.tasks.requests.post")
|
||||
def test_sends_mail_via_mailgun(self, mock_post):
|
||||
send_login_email_task("discoman@example.com", "http://example.com/login?token=abc123")
|
||||
self.assertEqual(mock_post.called, True)
|
||||
data = mock_post.call_args.kwargs["data"]
|
||||
self.assertEqual(data["subject"], "A magic login link to your Dashboard")
|
||||
self.assertEqual(data["from"], "adman@howdy.earthmanrpg.com")
|
||||
self.assertEqual(data["to"], "discoman@example.com")
|
||||
self.assertIn("http://example.com/login?token=abc123", data["text"])
|
||||
Reference in New Issue
Block a user