Skip to content

Commit

Permalink
Slight clean up #17
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Sep 30, 2024
1 parent bb54bd5 commit d8cb690
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
1 change: 0 additions & 1 deletion object_storage_api/stores/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def create(self, attachment: AttachmentPostSchema) -> tuple[AttachmentIn, Attach
object_key = f"attachments/{attachment.entity_id}/{attachment_id}"

logger.info("Generating a presigned URL for uploading the attachment")
# TODO: Handle failure here before creating the AttachmentPostUploadInfoSchema?
presigned_post_response = s3_client.generate_presigned_post(
Bucket=object_storage_config.bucket_name.get_secret_value(),
Key=object_key,
Expand Down
26 changes: 17 additions & 9 deletions test/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@
# Used for _GET_DATA's as when comparing these will not be possible to know at runtime
CREATED_MODIFIED_GET_DATA_EXPECTED = {"created_time": ANY, "modified_time": ANY}

# Used for _POST_RESPONSE_DATA's as when comparing most of these are not possible to know at runtime arguably we dont
# need to put the fields in but it ensures we capture potential changes to how boto3 functions
ATTACHMENT_UPLOAD_INFO_POST_RESPONSE_DATA_EXPECTED = {
"upload_info": {
"url": ANY,
"fields": {
"AWSAccessKeyId": ANY,
"Content-Type": "multipart/form-data",
"key": ANY,
"policy": ANY,
"signature": ANY,
},
}
}

# ---------------------------- ATTACHMENTS -----------------------------

# Required values only
Expand All @@ -29,15 +44,11 @@
"file_name": "report.txt",
}

# TODO: Create UPLOAD_INFO structure for these?
ATTACHMENT_POST_RESPONSE_DATA_REQUIRED_VALUES_ONLY = {
**ATTACHMENT_POST_DATA_REQUIRED_VALUES_ONLY,
**CREATED_MODIFIED_GET_DATA_EXPECTED,
**ATTACHMENT_UPLOAD_INFO_POST_RESPONSE_DATA_EXPECTED,
"id": ANY,
"upload_info": {
"url": ANY,
"fields": ANY,
},
"title": None,
"description": None,
}
Expand All @@ -60,9 +71,6 @@
ATTACHMENT_POST_RESPONSE_DATA_ALL_VALUES = {
**ATTACHMENT_POST_DATA_ALL_VALUES,
**CREATED_MODIFIED_GET_DATA_EXPECTED,
**ATTACHMENT_UPLOAD_INFO_POST_RESPONSE_DATA_EXPECTED,
"id": ANY,
"upload_info": {
"url": ANY,
"fields": ANY,
},
}

0 comments on commit d8cb690

Please sign in to comment.