Skip to content

Commit

Permalink
[#4319] Make title of document configurable in StUF-ZDS
Browse files Browse the repository at this point in the history
  • Loading branch information
vaszig committed Dec 12, 2024
1 parent 0b0a2a8 commit b95578a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/stuf/stuf_zds/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ def create_zaak_attachment(
doc_id=doc_id,
document=submission_attachment,
doc_data={
"titel": "bijlage",
"titel": submission_attachment.titel
or submission_attachment.get_display_name(),
"bestandsnaam": submission_attachment.get_display_name(),
"formaat": submission_attachment.content_type,
"beschrijving": "Bijgevoegd document",
Expand Down
58 changes: 58 additions & 0 deletions src/stuf/stuf_zds/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

from openforms.logging.models import TimelineLogProxy
from openforms.registrations.exceptions import RegistrationFailed
from openforms.submissions.models import SubmissionStep
from openforms.submissions.tests.factories import (
SubmissionFactory,
SubmissionFileAttachmentFactory,
SubmissionReportFactory,
)
Expand Down Expand Up @@ -453,6 +455,62 @@ def test_create_zaak_attachment(self, m):
1,
)

def test_create_zaak_attachment_with_custom_title(self, m):
client = StufZDSClient(self.service, self.options)
m.post(
self.service.soap_service.url,
content=load_mock("voegZaakdocumentToe.xml"),
additional_matcher=match_text("edcLk01"),
)

SubmissionFactory.from_components(
[
{
"key": "field1",
"type": "file",
"registration": {
"titel": "a custom title",
},
},
]
)

submission_attachment = SubmissionFileAttachmentFactory.create(
submission_step=SubmissionStep.objects.first(),
file_name="my-attachment.doc",
content_type="application/msword",
_component_configuration_path="components.0",
)

client.create_zaak_attachment(
zaak_id="foo", doc_id="bar", submission_attachment=submission_attachment
)
request = m.request_history[0]
self.assertEqual(
request.headers["SOAPAction"],
"http://www.egem.nl/StUF/sector/zkn/0310/voegZaakdocumentToe_Lk01",
)

xml_doc = xml_from_request_history(m, 0)
self.assertSoapXMLCommon(xml_doc)
self.assertXPathExists(xml_doc, "//zkn:edcLk01")
self.assertStuurgegevens(xml_doc)
self.assertXPathEqualDict(
xml_doc,
{
"//zkn:stuurgegevens/stuf:berichtcode": "Lk01",
"//zkn:stuurgegevens/stuf:entiteittype": "EDC",
"//zkn:object/zkn:identificatie": "bar",
"//zkn:object/zkn:dct.omschrijving": "dt-omschrijving",
"//zkn:object/zkn:inhoud/@stuf:bestandsnaam": "my-attachment.doc",
"//zkn:object/zkn:inhoud/@xmime:contentType": "application/msword",
"//zkn:object/zkn:formaat": "application/msword",
"//zkn:object/zkn:isRelevantVoor/zkn:gerelateerde/zkn:identificatie": "foo",
"//zkn:object/zkn:isRelevantVoor/zkn:gerelateerde/zkn:omschrijving": "my-form",
"//zkn:titel": "a custom title",
},
)

def test_client_wraps_network_error(self, m):
client = StufZDSClient(self.service, self.options)
m.post(self.service.soap_service.url, exc=RequestException)
Expand Down

0 comments on commit b95578a

Please sign in to comment.