Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reducing test flakiness #4948

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading