Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lambdas/services/staged_document_review_processing_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def handle_upload_document_reference_request(

document_reference = self._fetch_document_reference_by_id(upload_id)

if self._is_review_pending_upload(
document_reference
) and self._is_file_at_expected_location(document_reference, object_key):
if self._is_review_pending_upload(document_reference):
logger.info(
f"Document {document_reference.id} is in pending upload state, processing"
)
Expand Down Expand Up @@ -112,11 +110,11 @@ def _is_review_pending_upload(
== DocumentReviewStatus.REVIEW_PENDING_UPLOAD
)

def _is_file_at_expected_location(
self, document_reference: DocumentUploadReviewReference, object_key: str
) -> bool:
expected_file_location = document_reference.files[0].file_location
return expected_file_location.endswith(object_key)
# def _is_file_at_expected_location(
# self, document_reference: DocumentUploadReviewReference, object_key: str
# ) -> bool:
# expected_file_location = document_reference.files[0].file_location
# return expected_file_location.endswith(object_key)

def _perform_virus_scan(
self, document_reference: DocumentUploadReviewReference, object_key: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,23 +251,23 @@ def test_fetch_document_reference_by_id(
)


def test_handle_upload_document_reference_request_with_mismatched_object_key_and_file_location(
mock_service,
mock_review_document_service,
mock_virus_scan_service,
sample_document_reference,
):
object_key = "test-upload-id/test-document.pdf"
sample_document_reference.files[0].file_location = "s3://other-bucket/other-key.pdf"
mock_review_document_service.fetch_documents_from_table.return_value = [
sample_document_reference
]
mock_virus_scan_service.scan_file.return_value = VirusScanResult.CLEAN.value
mock_service.handle_upload_document_reference_request(object_key)

mock_virus_scan_service.scan_file.assert_not_called()
mock_service.s3_service.copy_across_bucket.assert_not_called()
mock_service.s3_service.delete_object.assert_called()
# def test_handle_upload_document_reference_request_with_mismatched_object_key_and_file_location(
# mock_service,
# mock_review_document_service,
# mock_virus_scan_service,
# sample_document_reference,
# ):
# object_key = "test-upload-id/test-document.pdf"
# sample_document_reference.files[0].file_location = "s3://other-bucket/other-key.pdf"
# mock_review_document_service.fetch_documents_from_table.return_value = [
# sample_document_reference
# ]
# mock_virus_scan_service.scan_file.return_value = VirusScanResult.CLEAN.value
# mock_service.handle_upload_document_reference_request(object_key)
#
# mock_virus_scan_service.scan_file.assert_not_called()
# mock_service.s3_service.copy_across_bucket.assert_not_called()
# mock_service.s3_service.delete_object.assert_called()


@pytest.mark.parametrize(
Expand Down
Loading