Skip to content

Commit

Permalink
Merge pull request #140 from GeneriekPublicatiePlatformWoo/bug/ignore…
Browse files Browse the repository at this point in the history
…-file-parts-on-regular-read-ops

Ignore file parts on regular read ops
  • Loading branch information
sergei-maertens authored Nov 14, 2024
2 parents 8f55a8b + 3f651bd commit cedb4aa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/woo_publications/publications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,10 @@ def zgw_document(self) -> ZGWDocument | None:
if not (self.document_service and self.document_uuid):
return None

raise NotImplementedError(
"Dynamically retrieving the 'zgw_document' is not yet implemented."
)
# at this time we do not dynamically look up the object in the upstream API,
# since evaluating this property in API detail/list responses adds significant
# overhead.
return None

@zgw_document.setter
def zgw_document(self, document: ZGWDocument) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,30 @@ def test_detail_document(self):

self.assertEqual(data, expected_data)

def test_read_endpoints_document_registered_in_documenten_api(self):
document = DocumentFactory.create(with_registered_document=True)

with self.subTest("list endpoint"):
endpoint = reverse("api:document-list")

response = self.client.get(endpoint, headers=AUDIT_HEADERS)

self.assertEqual(response.status_code, status.HTTP_200_OK)
# avoid hitting the documenten API for list endpoints
self.assertIsNone(response.json()["results"][0]["bestandsdelen"])

with self.subTest("detail endpoint"):
detail_url = reverse(
"api:document-detail",
kwargs={"uuid": str(document.uuid)},
)

response = self.client.get(detail_url, headers=AUDIT_HEADERS)

self.assertEqual(response.status_code, status.HTTP_200_OK)
# avoid hitting the documenten API for retrieve operations
self.assertIsNone(response.json()["bestandsdelen"])


@override_settings(ALLOWED_HOSTS=["testserver", "host.docker.internal"])
class DocumentApiCreateTests(VCRMixin, TokenAuthMixin, APITestCase):
Expand Down

0 comments on commit cedb4aa

Please sign in to comment.