Skip to content

Commit e5005ad

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

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
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/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-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,9 @@ 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,
41-
registration_success=True,
4241
form__registration_backend="zgw-create-zaak",
4342
form__registration_backend_options={"zgw_api_group": zgw_group.pk},
4443
form__payment_backend="ogone-legacy",

src/openforms/submissions/tests/test_post_submission_event.py

+19-14
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

@@ -796,7 +801,7 @@ def test_payment_status_update_retry_flow(self):
796801
},
797802
],
798803
submitted_data={"email": "test@test.nl", "cosign": "cosign@test.nl"},
799-
registration_success=True,
804+
with_public_registration_reference=True,
800805
cosign_request_email_sent=True,
801806
cosign_complete=True,
802807
cosign_confirmation_email_sent=True,
@@ -1000,7 +1005,7 @@ def test_payment_required_and_not_should_wait_for_registration(self):
10001005
"confirmationRecipient": True,
10011006
}
10021007
],
1003-
completed=True,
1008+
with_public_registration_reference=True,
10041009
form__registration_backend="email",
10051010
form__registration_backend_options={"to_emails": ["test@registration.nl"]},
10061011
form__product__price=10,
@@ -1051,7 +1056,7 @@ def test_payment_done_and_should_wait_for_payment(
10511056
form__registration_backend_options={"to_emails": ["test@registration.nl"]},
10521057
form__product__price=10,
10531058
form__payment_backend="demo",
1054-
completed=True,
1059+
with_public_registration_reference=True,
10551060
with_completed_payment=True,
10561061
)
10571062

@@ -1085,7 +1090,7 @@ def test_payment_done_and_not_should_wait_for_payment(
10851090
form__registration_backend_options={"to_emails": ["test@registration.nl"]},
10861091
form__product__price=10,
10871092
form__payment_backend="demo",
1088-
completed=True,
1093+
with_public_registration_reference=True,
10891094
with_completed_payment=True,
10901095
)
10911096

0 commit comments

Comments
 (0)