Skip to content

Commit

Permalink
Merge pull request #4948 from open-formulieren/fix/removing-test-flak…
Browse files Browse the repository at this point in the history
…yness

Reducing test flakiness
  • Loading branch information
sergei-maertens authored Dec 18, 2024
2 parents f796f25 + 6ad0ea7 commit b4a32bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/openforms/config/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Meta:


class MapTileLayerFactory(factory.django.DjangoModelFactory):
identifier = factory.Faker("word")
identifier = factory.Sequence(lambda n: f"map-tile-layer-{n}")
url = factory.Sequence(lambda n: f"http://example-{n}.com")
label = factory.Faker("word")

Expand Down
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 b4a32bd

Please sign in to comment.