generated from bisco/codex-bootstrap
fix: show local confirmation links before email send
This commit is contained in:
@@ -105,7 +105,7 @@ class BookingServiceTests(TestCase):
|
||||
SITE_BASE_URL="https://tickets.azionelab.example",
|
||||
)
|
||||
def test_create_pending_reservation_logs_confirmation_link_in_local_mode(self):
|
||||
with self.assertLogs("bookings.emailing", level="INFO") as captured_logs:
|
||||
with self.assertLogs("bookings.emailing", level="WARNING") as captured_logs:
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
result = create_pending_reservation(
|
||||
performance_id=self.performance.id,
|
||||
@@ -117,10 +117,7 @@ class BookingServiceTests(TestCase):
|
||||
self.assertEqual(result.reservation.status, Reservation.Status.PENDING)
|
||||
self.assertTrue(
|
||||
any(
|
||||
(
|
||||
"Local reservation confirmation link for manual testing "
|
||||
"(email send attempt)"
|
||||
) in log_entry
|
||||
"LOCAL DEV confirmation URL:" in log_entry
|
||||
and result.raw_confirmation_token in log_entry
|
||||
for log_entry in captured_logs.output
|
||||
)
|
||||
@@ -160,7 +157,7 @@ class BookingServiceTests(TestCase):
|
||||
self,
|
||||
mocked_send_mail,
|
||||
):
|
||||
with self.assertLogs("bookings.emailing", level="INFO") as captured_logs:
|
||||
with self.assertLogs("bookings.emailing", level="WARNING") as captured_logs:
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
result = create_pending_reservation(
|
||||
performance_id=self.performance.id,
|
||||
@@ -174,16 +171,13 @@ class BookingServiceTests(TestCase):
|
||||
confirmation_log_index = next(
|
||||
index
|
||||
for index, log_entry in enumerate(captured_logs.output)
|
||||
if (
|
||||
"Local reservation confirmation link for manual testing "
|
||||
"(email send attempt)"
|
||||
) in log_entry
|
||||
if "LOCAL DEV confirmation URL:" in log_entry
|
||||
and result.raw_confirmation_token in log_entry
|
||||
)
|
||||
failure_log_index = next(
|
||||
index
|
||||
for index, log_entry in enumerate(captured_logs.output)
|
||||
if "Failed to send confirmation email for reservation" in log_entry
|
||||
if "Local/debug email delivery failed for reservation" in log_entry
|
||||
)
|
||||
|
||||
self.assertLess(confirmation_log_index, failure_log_index)
|
||||
@@ -194,6 +188,9 @@ class BookingServiceTests(TestCase):
|
||||
),
|
||||
1,
|
||||
)
|
||||
self.assertFalse(
|
||||
any("Traceback" in log_entry for log_entry in captured_logs.output)
|
||||
)
|
||||
|
||||
@override_settings(
|
||||
LOG_RESERVATION_CONFIRMATION_URLS=False,
|
||||
@@ -204,7 +201,7 @@ class BookingServiceTests(TestCase):
|
||||
self,
|
||||
mocked_send_mail,
|
||||
):
|
||||
with self.assertNoLogs("bookings.emailing", level="INFO"):
|
||||
with self.assertNoLogs("bookings.emailing", level="WARNING"):
|
||||
with self.captureOnCommitCallbacks(execute=True):
|
||||
result = create_pending_reservation(
|
||||
performance_id=self.performance.id,
|
||||
|
||||
Reference in New Issue
Block a user