Skip to content

Commit fc77d65

Browse files
committed
[PRMP-909] add mock s3 copy response
1 parent 6b4afdd commit fc77d65

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

lambdas/tests/unit/helpers/data/s3_responses.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,27 @@
8282
],
8383
},
8484
]
85+
86+
MOCK_COPY_OBJECT_RESPONSE = {
87+
"CopyObjectResult": {
88+
"ETag": '"d41d8cd98f00b204e9800998ecf8427e"',
89+
"LastModified": "2024-06-01T12:34:56.000Z"
90+
},
91+
"Expiration": "expiry-date=\"2024-12-31T23:59:59Z\", rule-id=\"rule1\"",
92+
"CopySourceVersionId": "source-version-id",
93+
"VersionId": "new-version-id",
94+
"ResponseMetadata": {
95+
"RequestId": "EXAMPLE123456789",
96+
"HostId": "EXAMPLEHostId",
97+
"HTTPStatusCode": 200,
98+
"HTTPHeaders": {
99+
"x-amz-id-2": "EXAMPLEid2",
100+
"x-amz-request-id": "EXAMPLErequestid",
101+
"date": "Mon, 01 Jun 2024 12:34:56 GMT",
102+
"etag": '"d41d8cd98f00b204e9800998ecf8427e"',
103+
"content-length": "123",
104+
"server": "AmazonS3"
105+
},
106+
"RetryAttempts": 0
107+
}
108+
}

lambdas/tests/unit/services/test_bulk_upload_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
NAME_WITH_ACCENT_NFC_FORM,
4343
NAME_WITH_ACCENT_NFD_FORM,
4444
)
45+
from unit.helpers.data.s3_responses import MOCK_COPY_OBJECT_RESPONSE
4546
from utils.exceptions import (
4647
BulkUploadException,
4748
DocumentInfectedException,
@@ -712,8 +713,8 @@ def test_handle_sqs_message_rollback_transaction_when_validation_pass_but_file_t
712713

713714
# simulate a client error occur when copying the 3rd file
714715
repo_under_test.bulk_upload_s3_repository.copy_to_lg_bucket.side_effect = [
715-
None,
716-
None,
716+
MOCK_COPY_OBJECT_RESPONSE,
717+
MOCK_COPY_OBJECT_RESPONSE,
717718
mock_client_error,
718719
]
719720

0 commit comments

Comments
 (0)