Skip to content

Commit

Permalink
PRMP-1122 remove size, created and title from pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
NogaNHS committed Dec 6, 2024
1 parent 56ea062 commit 73d3a74
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lambdas/models/nrl_sqs_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class NrlAttachment(BaseModel):
content_type: str = "application/pdf"
language: str = "en-US"
language: str = "en-UK"
url: str = ""
size: int = 0
hash: str = ""
Expand Down
5 changes: 0 additions & 5 deletions lambdas/repositories/bulk_upload/bulk_upload_s3_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,3 @@ def rollback_transaction(self):

def file_exists_on_staging_bucket(self, file_key: str) -> bool:
return self.s3_repository.file_exist_on_s3(self.staging_bucket_name, file_key)

def file_size_on_lg_bucket(self, file_key: str) -> int:
return self.s3_repository.get_file_size(
s3_bucket_name=self.lg_bucket_name, object_key=file_key
)
6 changes: 0 additions & 6 deletions lambdas/services/bulk_upload_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,19 +274,13 @@ def handle_sqs_message(self, message: dict):
patient_ods_code,
)
if len(file_names) == 1:
file_size = self.s3_repository.file_size_on_lg_bucket(
last_document_processed.s3_file_key
)
document_api_endpoint = (
os.environ.get("APIM_API_URL", "")
+ "/DocumentReference/"
+ last_document_processed.id
)
doc_details = NrlAttachment(
url=document_api_endpoint,
size=file_size,
title=last_document_processed.file_name,
creation=last_document_processed.created,
)
nrl_sqs_message = NrlSqsMessage(
nhs_number=staging_metadata.nhs_number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,3 @@ def test_create_lg_records_and_copy_files_keep_track_of_successfully_ingested_fi
actual = repo_under_test.source_bucket_files_in_transaction

assert actual == expected


def test_file_size_on_lg_bucket(set_env, repo_under_test):
key = "mock_test_key"
repo_under_test.s3_repository.get_file_size.return_value = "111"

response = repo_under_test.file_size_on_lg_bucket(key)

assert response == "111"
10 changes: 1 addition & 9 deletions lambdas/tests/unit/services/test_bulk_upload_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,8 @@ def test_handle_sqs_message_happy_path_single_file(
mock_ods_validation,
):
TEST_STAGING_METADATA.retries = 0
mock_file_size = 300
mock_nrl_attachment = NrlAttachment(
url=f"/DocumentReference/{TEST_DOCUMENT_REFERENCE.id}",
creation=TEST_DOCUMENT_REFERENCE.created,
title=TEST_DOCUMENT_REFERENCE.file_name,
size=mock_file_size,
)
mock_nrl_message = NrlSqsMessage(
nhs_number=TEST_STAGING_METADATA.nhs_number,
Expand All @@ -261,11 +257,7 @@ def test_handle_sqs_message_happy_path_single_file(
repo_under_test.s3_repository, "remove_ingested_file_from_source_bucket"
)
mocker.patch.object(repo_under_test.s3_repository, "check_virus_result")
mocker.patch.object(
repo_under_test.s3_repository,
"file_size_on_lg_bucket",
return_value=mock_file_size,
)

repo_under_test.handle_sqs_message(message=TEST_SQS_MESSAGE_SINGLE_FILE)

mock_create_lg_records_and_copy_files.assert_called_with(
Expand Down

0 comments on commit 73d3a74

Please sign in to comment.