Skip to content

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GitRon committed May 27, 2024
1 parent 5ba94d5 commit e1be69b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def process(self, raise_exception: bool = True) -> None:
Public method which is called to actually send an email.
Calls validation first and returns the result of "msg.send()"
"""
# TODO(RV): test me
if self.is_valid(raise_exception=raise_exception):
msg = self._build_mail_object()
email_thread = threading.Thread(target=self._send_and_log_email, args=(msg,))
Expand Down
3 changes: 1 addition & 2 deletions django_pony_express/services/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
from django.utils import translation
from django.utils.translation import gettext_lazy as _

from django_pony_express.errors import EmailServiceAttachmentError, EmailServiceConfigError
from django_pony_express.settings import PONY_LOG_RECIPIENTS, PONY_LOGGER_NAME

from ..errors import EmailServiceAttachmentError, EmailServiceConfigError


class BaseEmailServiceFactory:
"""
Expand Down
Empty file.
19 changes: 19 additions & 0 deletions tests/services/asynchronous/test_thread_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from threading import Thread
from unittest import mock

from django.test import TestCase

from django_pony_express.services.asynchronous.thread import ThreadEmailService


class ThreadEmailServiceTest(TestCase):
@mock.patch.object(Thread, "start")
def test_process_regular(self, mocked_start):
email = "[email protected]"
subject = "Test email"
service = ThreadEmailService(recipient_email_list=[email])
service.subject = subject
service.template_name = "testapp/test_email.html"

self.assertIsNone(service.process())
mocked_start.assert_called_once()
2 changes: 1 addition & 1 deletion tests/services/base/test_base_mail_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def test_send_and_log_email_failure_privacy_active(self, mock_logger, *args):
@mock.patch.object(EmailMultiAlternatives, "send", side_effect=Exception("Broken pony"))
@mock.patch("django_pony_express.services.base.BaseEmailService._logger")
@mock.patch("django_pony_express.services.base.PONY_LOG_RECIPIENTS", True)
def test_send_and_log_success_privacy_inactive(self, mock_logger, *args):
def test_send_and_log_failure_privacy_inactive(self, mock_logger, *args):
service = BaseEmailService(recipient_email_list=["[email protected]"])
result = service._send_and_log_email(
msg=EmailMultiAlternatives(subject="The Pony Express", to=["[email protected]"])
Expand Down

0 comments on commit e1be69b

Please sign in to comment.