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 dfa17d1 commit 8bc5cd9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Added basic logging with privacy configuration to mail class
* Restructured documentation
* Restructured unit-tests
* Minor test improvements

* *2.0.0* (2024-04-11)
* Dropped Django 3.2 & 4.1 support (via `ambient-package-update`)
Expand Down
6 changes: 4 additions & 2 deletions django_pony_express/services/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import List

from django.core import mail
from django.core.mail import EmailMultiAlternatives
from django.test import TestCase


Expand Down Expand Up @@ -156,9 +157,10 @@ def __init__(self, matching_list=None):
super().__init__()
self._match_list = matching_list
for email in self._match_list or []:
# Change the class of every EmailMutliAlternative instance, so that it points to
# Change the class of every EmailMultiAlternative instance, so that it points to
# our subclass, which has some additional assertion-methods.
email.__class__ = EmailTestServiceMail
if isinstance(email, EmailMultiAlternatives):
email.__class__ = EmailTestServiceMail

def _get_html_content(self):
"""
Expand Down
1 change: 1 addition & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
)

USE_TZ = True
TIME_ZONE = "UTC"

LOCALE_PATHS = [str(BASE_PATH) + "/django_pony_express/locale"]
Expand Down
14 changes: 7 additions & 7 deletions tests/services/tests/test_email_test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,32 +200,32 @@ def test_assert_quantity_false(self):
self.ets.filter(subject=self.subject).assert_quantity(0)

def test_assert_subject_true(self):
self.ets.filter(subject=self.subject).assert_subject(self.subject)
self.ets.filter(subject=self.subject)[0].assert_subject(self.subject)

def test_assert_subject_false(self):
with self.assertRaises(AssertionError):
self.ets.filter(subject=self.subject).assert_subject(self.other_mail_subject)
self.ets.filter(subject=self.subject)[0].assert_subject(self.other_mail_subject)

def test_assert_body_contains_true(self):
self.ets.filter(subject=self.subject).assert_body_contains(self.content_part)
self.ets.filter(subject=self.subject)[0].assert_body_contains(self.content_part)

def test_assert_body_contains_false(self):
with self.assertRaises(AssertionError):
self.ets.filter(subject=self.subject).assert_body_contains("Not in here!")
self.ets.filter(subject=self.subject)[0].assert_body_contains("Not in here!")

def test_assert_body_contains_not_true(self):
self.ets.filter(subject=self.subject).assert_body_contains_not("Not in here!")
self.ets.filter(subject=self.subject)[0].assert_body_contains_not("Not in here!")

def test_assert_body_contains_not_false(self):
with self.assertRaises(AssertionError):
self.ets.filter(subject=self.subject).assert_body_contains_not(self.content_part)
self.ets.filter(subject=self.subject)[0].assert_body_contains_not(self.content_part)

def test_assert_body_contains_no_html_part(self):
subject = "No html email"
email = EmailMultiAlternatives(subject, self.text_content, to=[self.to], cc=[self.cc], bcc=[self.bcc])
mail.outbox.append(email)

self.ets.filter(subject=subject).assert_body_contains(self.content_part)
self.ets.filter(subject=subject)[0].assert_body_contains(self.content_part)

def test_can_get_mail_via_item(self):
mail_qs = self.ets.all()
Expand Down

0 comments on commit 8bc5cd9

Please sign in to comment.