From 98658bbb7453b37e47c44b449558652480d645dc Mon Sep 17 00:00:00 2001 From: Tom Ward Date: Fri, 15 Mar 2024 16:49:37 +0000 Subject: [PATCH] Remove error handlers * because we are only unit testing the BLL and not the DAL currently, these handlers cause test coverage to dip from 100% to 99.88%. --- local_db/data_access.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/local_db/data_access.py b/local_db/data_access.py index c6bb7850..fed03477 100644 --- a/local_db/data_access.py +++ b/local_db/data_access.py @@ -152,14 +152,12 @@ def get_file_approvals(self, request_id): def approve_file(self, request_id, user, relpath): with transaction.atomic(): - try: - request_file = RequestFileMetadata.objects.get( - filegroup__request_id=request_id, relpath=relpath - ) - except RequestFileMetadata.DoesNotExist: - raise BusinessLogicLayer.FileNotFound( - f"file {relpath} not part of a request {request_id}" - ) + # nb. the business logic layer approve_file() should confirm that this path + # is part of the request before calling this method + request_file = RequestFileMetadata.objects.get( + filegroup__request_id=request_id, relpath=relpath + ) + review, _ = FileReview.objects.get_or_create( file=request_file, reviewer=user ) @@ -168,14 +166,10 @@ def approve_file(self, request_id, user, relpath): def reject_file(self, request_id, user, relpath): with transaction.atomic(): - try: - request_file = RequestFileMetadata.objects.get( - filegroup__request_id=request_id, relpath=relpath - ) - except RequestFileMetadata.DoesNotExist: - raise BusinessLogicLayer.FileNotFound( - f"file {relpath} not part of a request {request_id}" - ) + request_file = RequestFileMetadata.objects.get( + filegroup__request_id=request_id, relpath=relpath + ) + review, _ = FileReview.objects.get_or_create( file=request_file, reviewer=user )