Skip to content

Commit 7f9b02e

Browse files
committed
[#3793] Hopefully fix remaining tests
1 parent 6b42e04 commit 7f9b02e

File tree

8 files changed

+36
-21
lines changed

8 files changed

+36
-21
lines changed

src/openforms/appointments/tests/test_views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ def test_invalid_auth_value_raises_exception(self):
803803

804804
def test_change_appointment_details_after_payment(self):
805805
submission = SubmissionFactory.from_components(
806-
completed=True,
806+
with_public_registration_reference=True,
807807
components_list=[
808808
{
809809
"key": "product",

src/openforms/emails/tests/test_confirmation_email.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def test_email_payment_incomplete(self):
432432
def test_email_payment_completed(self):
433433
email = ConfirmationEmailTemplate(content="test {% payment_information %}")
434434
submission = SubmissionFactory.create(
435-
completed=True,
435+
with_public_registration_reference=True,
436436
form__product__price=Decimal("12.34"),
437437
form__payment_backend="test",
438438
)

src/openforms/payments/tests/test_e2e.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77
from asgiref.sync import sync_to_async
88
from furl import furl
9-
from playwright.async_api import expect
9+
from playwright.async_api import Route, expect
1010
from rest_framework.test import APIRequestFactory
1111

1212
from openforms.forms.tests.factories import FormFactory
1313
from openforms.submissions.constants import ProcessingStatuses
14+
from openforms.submissions.models import Submission
1415
from openforms.tests.e2e.base import E2ETestCase, browser_page
1516

1617
factory = APIRequestFactory()
@@ -32,9 +33,18 @@ def get_form_url(self):
3233

3334
return form
3435

35-
async def mock_status_url(self, route):
36+
@sync_to_async
37+
def set_submission_reference(self) -> None:
38+
# Required as payment will use the submission ref.
39+
submission = Submission.objects.last()
40+
submission.public_registration_reference = "OF-123456"
41+
submission.save()
42+
43+
async def mock_status_url(self, route: Route):
3644
response = await route.fetch()
3745
json = await response.json()
46+
await self.set_submission_reference()
47+
3848
json["status"] = ProcessingStatuses.done
3949
submission_uuid = resolve(furl(route.request.url).path).kwargs["uuid"]
4050
json["paymentUrl"] = str(

src/openforms/registrations/contrib/objects_api/tests/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_render_to_json_many_decimal_places(self):
9090
self.assertEqual("3.14", context_data["amount"])
9191

9292
def test_multiple_public_order_ids(self):
93-
submission = SubmissionFactory.create()
93+
submission = SubmissionFactory.create(with_public_registration_reference=True)
9494
payment1, payment2 = SubmissionPaymentFactory.create_batch(
9595
2, submission=submission, status=PaymentStatus.completed, amount=10
9696
)

src/openforms/registrations/tasks.py

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ def register_submission(submission_id: int, event: PostSubmissionEvents) -> None
122122
submission = Submission.objects.select_related("auth_info", "form").get(
123123
id=submission_id
124124
)
125-
126125
logger.debug("Register submission '%s'", submission)
127126

128127
if submission.registration_status == RegistrationStatuses.success:

src/openforms/submissions/tests/factories.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class Params:
140140
),
141141
)
142142
with_public_registration_reference = factory.Trait(
143-
registration_success=True,
143+
completed=True,
144144
public_registration_reference=factory.LazyFunction(get_random_reference),
145145
)
146146

src/openforms/submissions/tests/test_on_completion_retry_chain.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_payment_status_update_now_succeeds(self):
3535
zgw_group = ZGWApiGroupConfigFactory.create()
3636
# set up a complex submission, with an appointment and payment required.
3737
submission = SubmissionFactory.create(
38-
completed=True,
38+
with_public_registration_reference=True,
3939
# set by :func:`openforms.payments.tasks.update_submission_payment_status`
4040
needs_on_completion_retry=True,
4141
registration_success=True,

src/openforms/submissions/tests/test_post_submission_event.py

+19-13
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ def test_submission_completed_payment_needed(self):
198198
subject="Confirmation of your {{ form_name }} submission",
199199
content="Custom content {% appointment_information %} {% payment_information %} {% cosign_information %}",
200200
)
201-
SubmissionPaymentFactory.create(
202-
submission=submission, amount=10, status=PaymentStatus.started
203-
)
204201

205202
with (
206203
patch(
@@ -222,6 +219,11 @@ def test_submission_completed_payment_needed(self):
222219

223220
submission.refresh_from_db()
224221

222+
# We then create the submission payment, as it requires a public reference
223+
SubmissionPaymentFactory.create(
224+
submission=submission, amount=10, status=PaymentStatus.started
225+
)
226+
225227
self.assertEqual(submission.public_registration_reference, "OF-TEST!")
226228
self.assertTrue(SubmissionReport.objects.filter(submission=submission).exists())
227229
mock_registration.assert_called()
@@ -283,9 +285,6 @@ def test_submission_completed_payment_and_cosign_needed(self):
283285
subject="Confirmation of your {{ form_name }} submission",
284286
content="Custom content {% appointment_information %} {% payment_information %} {% cosign_information %}",
285287
)
286-
SubmissionPaymentFactory.create(
287-
submission=submission, amount=10, status=PaymentStatus.started
288-
)
289288

290289
with (
291290
patch(
@@ -303,6 +302,11 @@ def test_submission_completed_payment_and_cosign_needed(self):
303302

304303
submission.refresh_from_db()
305304

305+
# We then create the submission payment, as it requires a public reference
306+
SubmissionPaymentFactory.create(
307+
submission=submission, amount=10, status=PaymentStatus.started
308+
)
309+
306310
self.assertEqual(submission.public_registration_reference, "OF-TEST!")
307311
self.assertTrue(SubmissionReport.objects.filter(submission=submission).exists())
308312
mock_registration.assert_not_called()
@@ -424,7 +428,7 @@ def test_cosign_done_payment_needed_not_done(self):
424428
},
425429
],
426430
submitted_data={"email": "test@test.nl", "cosign": "cosign@test.nl"},
427-
completed=True,
431+
with_public_registration_reference=True,
428432
cosign_request_email_sent=True,
429433
cosign_complete=True,
430434
confirmation_email_sent=True,
@@ -509,7 +513,7 @@ def test_cosign_done_payment_done(self):
509513
},
510514
],
511515
submitted_data={"email": "test@test.nl", "cosign": "cosign@test.nl"},
512-
completed=True,
516+
with_public_registration_reference=True,
513517
cosign_request_email_sent=True,
514518
cosign_complete=True,
515519
confirmation_email_sent=True,
@@ -584,7 +588,7 @@ def test_payment_done_cosign_not_needed(self):
584588
},
585589
],
586590
submitted_data={"email": "test@test.nl"},
587-
completed=True,
591+
with_public_registration_reference=True,
588592
confirmation_email_sent=True,
589593
form__registration_backend="email",
590594
form__registration_backend_options={"to_emails": ["test@registration.nl"]},
@@ -663,7 +667,7 @@ def test_payment_done_cosign_needed_not_done(self):
663667
},
664668
],
665669
submitted_data={"email": "test@test.nl", "cosign": "cosign@test.nl"},
666-
completed=True,
670+
with_public_registration_reference=True,
667671
cosign_request_email_sent=True,
668672
cosign_complete=False,
669673
cosign_confirmation_email_sent=False,
@@ -753,6 +757,7 @@ def test_retry_flow(self):
753757
auth_info__value="111222333",
754758
needs_on_completion_retry=True,
755759
registration_failed=True,
760+
with_public_registration_reference=True,
756761
with_completed_payment=True,
757762
)
758763

@@ -809,6 +814,7 @@ def test_payment_status_update_retry_flow(self):
809814
auth_info__value="111222333",
810815
needs_on_completion_retry=True,
811816
with_completed_payment=True,
817+
with_public_registration_reference=True,
812818
)
813819

814820
with (
@@ -1000,7 +1006,7 @@ def test_payment_required_and_not_should_wait_for_registration(self):
10001006
"confirmationRecipient": True,
10011007
}
10021008
],
1003-
completed=True,
1009+
with_public_registration_reference=True,
10041010
form__registration_backend="email",
10051011
form__registration_backend_options={"to_emails": ["test@registration.nl"]},
10061012
form__product__price=10,
@@ -1051,7 +1057,7 @@ def test_payment_done_and_should_wait_for_payment(
10511057
form__registration_backend_options={"to_emails": ["test@registration.nl"]},
10521058
form__product__price=10,
10531059
form__payment_backend="demo",
1054-
completed=True,
1060+
with_public_registration_reference=True,
10551061
with_completed_payment=True,
10561062
)
10571063

@@ -1085,7 +1091,7 @@ def test_payment_done_and_not_should_wait_for_payment(
10851091
form__registration_backend_options={"to_emails": ["test@registration.nl"]},
10861092
form__product__price=10,
10871093
form__payment_backend="demo",
1088-
completed=True,
1094+
with_public_registration_reference=True,
10891095
with_completed_payment=True,
10901096
)
10911097

0 commit comments

Comments
 (0)