Skip to content

Commit

Permalink
🧐 Try to figure out why test is sometimes failing
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Dec 18, 2024
1 parent fc61f82 commit 6ad0ea7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/openforms/submissions/tests/test_post_submission_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
from openforms.emails.tests.factories import ConfirmationEmailTemplateFactory
from openforms.forms.constants import LogicActionTypes, PropertyTypes
from openforms.forms.tests.factories import FormLogicFactory
from openforms.logging.models import TimelineLogProxy
from openforms.payments.constants import PaymentStatus
from openforms.payments.tests.factories import SubmissionPaymentFactory
from openforms.registrations.base import PreRegistrationResult
from openforms.registrations.contrib.zgw_apis.tests.factories import (
ZGWApiGroupConfigFactory,
)
from openforms.tests.utils import log_flaky
from openforms.utils.tests.logging import ensure_logger_level

from ..constants import PostSubmissionEvents, RegistrationStatuses
Expand Down Expand Up @@ -893,8 +895,24 @@ def test_cosign_not_required_and_not_filled_in_proceeds_with_registration(self):
mock_payment_status_update.assert_not_called()

mails = mail.outbox
submission.refresh_from_db()

# FLAKINESS HERE happens something, try to figure out what's going wrong
if not mails:
log_flaky()

# try to detect why no registration email was sent
print(f"{submission.registration_status=}")
print(f"{submission.payment_required=}")
print(f"{submission.confirmation_email_sent=}")
print(f"{submission.form.send_confirmation_email=}")
# and print logevents
logs = TimelineLogProxy.objects.for_object(submission)
for log in logs:
print(log.message().strip())

self.assertEqual(len(mails), 1) # No cosign request email!

self.assertEqual(1, len(mails)) # No cosign request email!
self.assertEqual(
mails[0].subject, "Confirmation of your Pretty Form submission"
)
Expand All @@ -905,8 +923,6 @@ def test_cosign_not_required_and_not_filled_in_proceeds_with_registration(self):

self.assertNotIn(cosign_info, mails[0].body.strip("\n"))

submission.refresh_from_db()

self.assertFalse(submission.cosign_request_email_sent)
self.assertTrue(submission.confirmation_email_sent)
self.assertNotEqual(submission.auth_info.value, "111222333")
Expand Down

0 comments on commit 6ad0ea7

Please sign in to comment.