Skip to content

Commit

Permalink
Rename inline to view in var names #93
Browse files Browse the repository at this point in the history
  • Loading branch information
asuresh-code committed Jan 16, 2025
1 parent 5da061b commit f87998e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion object_storage_api/schemas/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ class ImageMetadataSchema(CreatedModifiedSchemaMixin, ImagePostMetadataSchema):
class ImageSchema(ImageMetadataSchema):
"""Schema model for an image get request response."""

inline_url: HttpUrl = Field(description="Presigned get URL to view the image file")
view_url: HttpUrl = Field(description="Presigned get URL to view the image file")
download_url: HttpUrl = Field(description="Presigned get URL to download the image file")
6 changes: 3 additions & 3 deletions object_storage_api/services/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ def create(self, image_metadata: ImagePostMetadataSchema, upload_file: UploadFil

def get(self, image_id: str) -> ImageSchema:
"""
Retrieve an image's metadata with its presigned get download and inline urls by its ID.
Retrieve an image's metadata with its presigned get download and view urls by its ID.
:param image_id: ID of the image to retrieve.
:return: An image's metadata with its presigned get urls.
"""
image = self._image_repository.get(image_id=image_id)
(inline_url, download_url) = self._image_store.create_presigned_get(image)
return ImageSchema(**image.model_dump(), inline_url=inline_url, download_url=download_url)
(view_url, download_url) = self._image_store.create_presigned_get(image)
return ImageSchema(**image.model_dump(), view_url=view_url, download_url=download_url)

def list(self, entity_id: Optional[str] = None, primary: Optional[bool] = None) -> list[ImageMetadataSchema]:
"""
Expand Down
4 changes: 2 additions & 2 deletions object_storage_api/stores/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def create_presigned_get(self, image: ImageOut) -> tuple[str, str]:
"ExpiresIn": object_storage_config.presigned_url_expiry_seconds,
}

inline_response = s3_client.generate_presigned_url(**parameters)
view_response = s3_client.generate_presigned_url(**parameters)

attachment_response = s3_client.generate_presigned_url(
**{
Expand All @@ -70,7 +70,7 @@ def create_presigned_get(self, image: ImageOut) -> tuple[str, str]:
}
)

return (inline_response, attachment_response)
return (view_response, attachment_response)

def delete(self, object_key: str) -> None:
"""
Expand Down
2 changes: 1 addition & 1 deletion test/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,6 @@

IMAGE_GET_DATA_ALL_VALUES = {
**IMAGE_GET_METADATA_DATA_ALL_VALUES,
"inline_url": ANY,
"view_url": ANY,
"download_url": ANY,
}
2 changes: 1 addition & 1 deletion test/unit/services/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def mock_get(self) -> None:
)
self._expected_image = ImageSchema(
**self._expected_image_out.model_dump(),
inline_url="https://fakepresignedurl.co.uk/inline",
view_url="https://fakepresignedurl.co.uk/inline",
download_url="https://fakepresignedurl.co.uk/attachment",
)

Expand Down
12 changes: 6 additions & 6 deletions test/unit/stores/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class CreatePresignedURLDSL(ImageStoreDSL):
"""Base class for `create` tests."""

_image_out: ImageOut
_expected_presigned_inline_url: str
_obtained_presigned_inline_url: str
_expected_presigned_view_url: str
_obtained_presigned_view_url: str
_expected_presigned_download_url: str
_obtained_presigned_download_url: str

Expand All @@ -133,10 +133,10 @@ def mock_create_presigned_get(self, image_in_data: dict) -> None:
self._image_out = ImageOut(**ImageIn(**image_in_data).model_dump())

# Mock presigned url generation
self._expected_presigned_inline_url = "example_presigned_inline_url"
self._expected_presigned_view_url = "example_presigned_view_url"
self._expected_presigned_download_url = "example_presigned_downloadurl"
self.mock_s3_client.generate_presigned_url.side_effect = [
self._expected_presigned_inline_url,
self._expected_presigned_view_url,
self._expected_presigned_download_url,
]

Expand All @@ -146,7 +146,7 @@ def call_create_presigned_get(self) -> None:
`mock_create_presigned_get`.
"""

(self._obtained_presigned_inline_url, self._obtained_presigned_download_url) = (
(self._obtained_presigned_view_url, self._obtained_presigned_download_url) = (
self.image_store.create_presigned_get(self._image_out)
)

Expand Down Expand Up @@ -177,7 +177,7 @@ def check_create_presigned_get_success(self) -> None:
]
self.mock_s3_client.assert_has_calls(expected_calls)

assert self._obtained_presigned_inline_url == self._expected_presigned_inline_url
assert self._obtained_presigned_view_url == self._expected_presigned_view_url
assert self._obtained_presigned_download_url == self._expected_presigned_download_url


Expand Down

0 comments on commit f87998e

Please sign in to comment.