generated from bisco/codex-bootstrap
test: capture expected email failure logs
This commit is contained in:
@@ -82,6 +82,7 @@ class BookingServiceTests(TestCase):
|
|||||||
|
|
||||||
@patch("bookings.emailing.send_mail", side_effect=RuntimeError("SMTP down"))
|
@patch("bookings.emailing.send_mail", side_effect=RuntimeError("SMTP down"))
|
||||||
def test_create_pending_reservation_logs_email_failure_without_crashing(self, mocked_send_mail):
|
def test_create_pending_reservation_logs_email_failure_without_crashing(self, mocked_send_mail):
|
||||||
|
with self.assertLogs("bookings.emailing", level="ERROR") as captured_logs:
|
||||||
result = create_pending_reservation(
|
result = create_pending_reservation(
|
||||||
performance_id=self.performance.id,
|
performance_id=self.performance.id,
|
||||||
name="Maria Rossi",
|
name="Maria Rossi",
|
||||||
@@ -92,6 +93,12 @@ class BookingServiceTests(TestCase):
|
|||||||
self.assertEqual(result.reservation.status, Reservation.Status.PENDING)
|
self.assertEqual(result.reservation.status, Reservation.Status.PENDING)
|
||||||
self.assertEqual(Reservation.objects.count(), 1)
|
self.assertEqual(Reservation.objects.count(), 1)
|
||||||
mocked_send_mail.assert_called_once()
|
mocked_send_mail.assert_called_once()
|
||||||
|
self.assertTrue(
|
||||||
|
any(
|
||||||
|
"Failed to send confirmation email for reservation" in log_entry
|
||||||
|
for log_entry in captured_logs.output
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def test_generate_confirmation_token_returns_raw_token_once(self):
|
def test_generate_confirmation_token_returns_raw_token_once(self):
|
||||||
reservation = self.create_reservation()
|
reservation = self.create_reservation()
|
||||||
|
|||||||
Reference in New Issue
Block a user