Skip to content

Commit

Permalink
base changes to Dynamo DB structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Alexander committed Feb 26, 2024
1 parent 449839a commit 1ee9f30
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lambdas/enums/metadata_field_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class DocumentReferenceMetadataFields(Enum):
TTL = "TTL"
TYPE = "Type"
VIRUS_SCANNER_RESULT = "VirusScannerResult"
CURRENT_GP_ODS = "CurrentGpOds"
CURRENT_GP_ODS = "CurrentGpOds",
UPLOADED = 'Uploaded'

@staticmethod
def list() -> list[str]:
Expand Down
4 changes: 4 additions & 0 deletions lambdas/models/document_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class DocumentReference(BaseModel):
alias=str(DocumentReferenceMetadataFields.CURRENT_GP_ODS.value), default=None
)

uploaded: str = Field(
alias=str(DocumentReferenceMetadataFields.UPLOADED.value), default=False
)

def get_file_name_path(self):
return pathlib.Path(self.file_name)

Expand Down
2 changes: 2 additions & 0 deletions lambdas/models/nhs_document_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
self.deleted = ""
self.virus_scanner_result = "Not Scanned"
self.file_location = f"s3://{self.s3_bucket_name}/{self.s3_file_key}"
self.uploaded = False

def set_deleted(self) -> None:
self.deleted = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
Expand All @@ -51,6 +52,7 @@ def to_dict(self):
DocumentReferenceMetadataFields.CONTENT_TYPE.value: self.content_type,
DocumentReferenceMetadataFields.VIRUS_SCANNER_RESULT.value: self.virus_scanner_result,
DocumentReferenceMetadataFields.CURRENT_GP_ODS.value: self.current_gp_ods,
DocumentReferenceMetadataFields.UPLOADED.value: self.uploaded,
}
return document_metadata

Expand Down
4 changes: 3 additions & 1 deletion lambdas/tests/unit/enums/test_metadata_field_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ def test_can_get_one_field_name():

def test_returns_all_as_list():
subject = DocumentReferenceMetadataFields.list()
assert len(subject) == 11
print(subject)
assert len(subject) == 12
assert DocumentReferenceMetadataFields.ID.value in subject
assert DocumentReferenceMetadataFields.CONTENT_TYPE.value in subject
assert DocumentReferenceMetadataFields.CREATED.value in subject
Expand All @@ -20,3 +21,4 @@ def test_returns_all_as_list():
assert DocumentReferenceMetadataFields.TTL.value in subject
assert DocumentReferenceMetadataFields.VIRUS_SCANNER_RESULT.value in subject
assert DocumentReferenceMetadataFields.CURRENT_GP_ODS.value in subject
assert DocumentReferenceMetadataFields.UPLOADED.value in subject

0 comments on commit 1ee9f30

Please sign in to comment.