From e41b5962d71cc7af4581fae018e5d1a97e565884 Mon Sep 17 00:00:00 2001 From: Paul Hewlett Date: Fri, 12 Jul 2024 16:45:41 +0100 Subject: [PATCH] Fix assetattachments tests AB#9685 --- archivist/assetattachments.py | 8 ++++---- unittests/testpublicassetattachments.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/archivist/assetattachments.py b/archivist/assetattachments.py index a6de7040..5e8c26d7 100644 --- a/archivist/assetattachments.py +++ b/archivist/assetattachments.py @@ -76,11 +76,11 @@ def _identity(self, identity: str, attachment_id: str) -> str: identity looks like: - [https://app.datatrails.ai/archivist/public]assets/xxxxxxx + [https://app.datatrails.ai/archivist/v2/public]assets/xxxxxxx OR - [https://app.datatrails.ai/archivist/public]assets/xxxxxxx/events/yyyyyy + [https://app.datatrails.ai/archivist/v2/public]assets/xxxxxxx/events/yyyyyy where the public URL is prefixed with the schema. @@ -89,8 +89,8 @@ def _identity(self, identity: str, attachment_id: str) -> str: if self._public: # the public URL for the asset or event has to be changed url = urlparse(identity) - root = "/".join(url.path.split(SEP)[:2]) - asset_id = "/".join(url.path.split(SEP)[2:]) + root = SEP.join(url.path.split(SEP)[:2]) + asset_id = SEP.join(url.path.split(SEP)[3:]) new_url = url._replace( path=f"{root}/{ASSETATTACHMENTS_SUBPATH}/{ASSETATTACHMENTS_LABEL}/{asset_id}/{uuid}" ) diff --git a/unittests/testpublicassetattachments.py b/unittests/testpublicassetattachments.py index dd97725c..91abe301 100644 --- a/unittests/testpublicassetattachments.py +++ b/unittests/testpublicassetattachments.py @@ -37,14 +37,15 @@ } URL = "https://app.datatrails.ai" ASSET_UUID = "b2678528-0136-4876-ad56-904e12c4b4c6" -ASSET_ID = f"{URL}/{ROOT}/public{ASSETS_LABEL}/{ASSET_UUID}" +ASSET_ID = f"{URL}/{ROOT}/v2/public{ASSETS_LABEL}/{ASSET_UUID}" ATTACHMENT_UUID = "abcdef28-0136-4876-ad56-904e12c4b4c6" ATTACHMENT_ID = f"{ATTACHMENTS_LABEL}/{ATTACHMENT_UUID}" SUBPATH = ( f"{ASSETATTACHMENTS_SUBPATH}/{ASSETATTACHMENTS_LABEL}/" f"public{ASSETS_LABEL}/{ASSET_UUID}/{ATTACHMENT_UUID}" ) -LOGGER.debug("Subpath %s", SUBPATH) + +LOGGER.debug("Subpath %s/%s/%s", URL, ROOT, SUBPATH) RESPONSE = { **PROPS, "identity": ATTACHMENT_ID,