From fc61f8237902d67b1c6156a12187000a8d47037a Mon Sep 17 00:00:00 2001 From: robinvandermolen Date: Wed, 18 Dec 2024 10:59:26 +0100 Subject: [PATCH 1/2] :white_check_mark: Reducing test flakiness Making sure that the unique mapTileLayer identifier uses unique test values --- src/openforms/config/tests/factories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openforms/config/tests/factories.py b/src/openforms/config/tests/factories.py index 08476e714b..745819c796 100644 --- a/src/openforms/config/tests/factories.py +++ b/src/openforms/config/tests/factories.py @@ -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") From 6ad0ea716bb4654829d0bf1ea14735658a0e6d5e Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Wed, 18 Dec 2024 12:27:45 +0100 Subject: [PATCH 2/2] :monocle_face: Try to figure out why test is sometimes failing --- .../tests/test_post_submission_event.py | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/openforms/submissions/tests/test_post_submission_event.py b/src/openforms/submissions/tests/test_post_submission_event.py index e4a975d28b..739c9a0712 100644 --- a/src/openforms/submissions/tests/test_post_submission_event.py +++ b/src/openforms/submissions/tests/test_post_submission_event.py @@ -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 @@ -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" ) @@ -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")