Skip to content

Commit a3d52b3

Browse files
💚 Fix CI failure
The test was failing because there already is factory-level machinery that ensures the form/submission variables exist as expected.
1 parent 0419a27 commit a3d52b3

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

src/openforms/submissions/tests/factories.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ class SubmissionValueVariableFactory(factory.django.DjangoModelFactory):
417417

418418
class Meta:
419419
model = SubmissionValueVariable
420-
django_get_or_create = ("submission", "form_variable")
420+
django_get_or_create = ("submission", "key")
421421

422422

423423
class PostCompletionMetadataFactory(factory.django.DjangoModelFactory):

src/openforms/submissions/tests/test_submission_attachment.py

+29-35
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
SubmissionFactory,
2727
SubmissionFileAttachmentFactory,
2828
SubmissionStepFactory,
29-
SubmissionValueVariableFactory,
3029
TemporaryFileUploadFactory,
3130
)
3231

@@ -490,7 +489,34 @@ def test_attach_uploads_to_submission_step_with_nested_fields(self, resize_mock)
490489
def test_attach_uploads_to_submission_step_with_nested_fields_with_matching_keys(
491490
self, resize_mock
492491
):
493-
submission = SubmissionFactory.create()
492+
submission = SubmissionFactory.create(
493+
form__generate_minimal_setup=True,
494+
form__formstep__form_definition__configuration={
495+
"components": [
496+
{
497+
"key": "repeatingGroup",
498+
"type": "editgrid",
499+
"components": [
500+
{
501+
"type": "file",
502+
"key": "attachment",
503+
"registration": {
504+
"informatieobjecttype": "http://oz.nl/catalogi/api/v1/informatieobjecttypen/123-123-123"
505+
},
506+
}
507+
],
508+
},
509+
{
510+
"key": "attachment",
511+
"type": "file",
512+
"registration": {
513+
"informatieobjecttype": "http://oz.nl/catalogi/api/v1/informatieobjecttypen/456-456-456"
514+
},
515+
},
516+
]
517+
},
518+
)
519+
form_step = submission.form.formstep_set.get()
494520
attachment_1 = TemporaryFileUploadFactory.create(
495521
submission=submission, file_name="attachmentInside.pdf"
496522
)
@@ -539,42 +565,10 @@ def test_attach_uploads_to_submission_step_with_nested_fields_with_matching_keys
539565
}
540566
],
541567
}
542-
components = [
543-
{
544-
"key": "repeatingGroup",
545-
"type": "editgrid",
546-
"components": [
547-
{
548-
"type": "file",
549-
"key": "attachment",
550-
"registration": {
551-
"informatieobjecttype": "http://oz.nl/catalogi/api/v1/informatieobjecttypen/123-123-123"
552-
},
553-
}
554-
],
555-
},
556-
{
557-
"key": "attachment",
558-
"type": "file",
559-
"registration": {
560-
"informatieobjecttype": "http://oz.nl/catalogi/api/v1/informatieobjecttypen/456-456-456"
561-
},
562-
},
563-
]
564-
form_step = FormStepFactory.create(
565-
form=submission.form,
566-
form_definition__configuration={"components": components},
567-
)
568568
submission_step = SubmissionStepFactory.create(
569569
form_step=form_step, submission=submission, data=data
570570
)
571-
# TODO: remove once #2728 is fixed
572-
SubmissionValueVariableFactory.create(
573-
key="attachment",
574-
form_variable__form=form_step.form,
575-
submission=submission,
576-
value=data["attachment"],
577-
)
571+
assert submission.submissionvaluevariable_set.get(key="attachment").pk
578572

579573
result = attach_uploads_to_submission_step(submission_step)
580574

0 commit comments

Comments
 (0)