Skip to content

Commit

Permalink
💚 Fix CI failure
Browse files Browse the repository at this point in the history
The test was failing because there already is factory-level machinery
that ensures the form/submission variables exist as expected.

(cherry picked from commit a3d52b3)
  • Loading branch information
sergei-maertens committed Feb 6, 2025
1 parent 2fb7263 commit 7da1dba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/openforms/submissions/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class SubmissionValueVariableFactory(factory.django.DjangoModelFactory):

class Meta:
model = SubmissionValueVariable
django_get_or_create = ("submission", "form_variable")
django_get_or_create = ("submission", "key")


class PostCompletionMetadataFactory(factory.django.DjangoModelFactory):
Expand Down
64 changes: 29 additions & 35 deletions src/openforms/submissions/tests/test_submission_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
SubmissionFactory,
SubmissionFileAttachmentFactory,
SubmissionStepFactory,
SubmissionValueVariableFactory,
TemporaryFileUploadFactory,
)

Expand Down Expand Up @@ -490,7 +489,34 @@ def test_attach_uploads_to_submission_step_with_nested_fields(self, resize_mock)
def test_attach_uploads_to_submission_step_with_nested_fields_with_matching_keys(
self, resize_mock
):
submission = SubmissionFactory.create()
submission = SubmissionFactory.create(
form__generate_minimal_setup=True,
form__formstep__form_definition__configuration={
"components": [
{
"key": "repeatingGroup",
"type": "editgrid",
"components": [
{
"type": "file",
"key": "attachment",
"registration": {
"informatieobjecttype": "http://oz.nl/catalogi/api/v1/informatieobjecttypen/123-123-123"
},
}
],
},
{
"key": "attachment",
"type": "file",
"registration": {
"informatieobjecttype": "http://oz.nl/catalogi/api/v1/informatieobjecttypen/456-456-456"
},
},
]
},
)
form_step = submission.form.formstep_set.get()
attachment_1 = TemporaryFileUploadFactory.create(
submission=submission, file_name="attachmentInside.pdf"
)
Expand Down Expand Up @@ -539,42 +565,10 @@ def test_attach_uploads_to_submission_step_with_nested_fields_with_matching_keys
}
],
}
components = [
{
"key": "repeatingGroup",
"type": "editgrid",
"components": [
{
"type": "file",
"key": "attachment",
"registration": {
"informatieobjecttype": "http://oz.nl/catalogi/api/v1/informatieobjecttypen/123-123-123"
},
}
],
},
{
"key": "attachment",
"type": "file",
"registration": {
"informatieobjecttype": "http://oz.nl/catalogi/api/v1/informatieobjecttypen/456-456-456"
},
},
]
form_step = FormStepFactory.create(
form=submission.form,
form_definition__configuration={"components": components},
)
submission_step = SubmissionStepFactory.create(
form_step=form_step, submission=submission, data=data
)
# TODO: remove once #2728 is fixed
SubmissionValueVariableFactory.create(
key="attachment",
form_variable__form=form_step.form,
submission=submission,
value=data["attachment"],
)
assert submission.submissionvaluevariable_set.get(key="attachment").pk

result = attach_uploads_to_submission_step(submission_step)

Expand Down

0 comments on commit 7da1dba

Please sign in to comment.