mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-18 13:40:31 -04:00
add tests
This commit is contained in:
@@ -7,7 +7,7 @@ from requests import (
|
||||
post as requests_post,
|
||||
RequestException
|
||||
)
|
||||
|
||||
from celery.exceptions import MaxRetriesExceededError
|
||||
from notifications_utils.statsd_decorators import statsd
|
||||
from notifications_utils.s3 import s3upload
|
||||
|
||||
@@ -70,7 +70,7 @@ def create_letters_pdf(self, notification_id):
|
||||
"Letters PDF notification creation for id: {} failed".format(notification_id)
|
||||
)
|
||||
self.retry(queue=QueueNames.RETRY)
|
||||
except self.MaxRetriesExceededError:
|
||||
except MaxRetriesExceededError:
|
||||
current_app.logger.exception(
|
||||
"RETRY FAILED: task create_letters_pdf failed for notification {}".format(notification_id),
|
||||
)
|
||||
@@ -228,7 +228,7 @@ def _sanitise_precomiled_pdf(self, notification, precompiled_pdf):
|
||||
resp.raise_for_status()
|
||||
return resp.content
|
||||
except RequestException as ex:
|
||||
if ex.status_code == 400:
|
||||
if ex.response is not None and ex.response.status_code == 400:
|
||||
# validation error
|
||||
return None
|
||||
|
||||
@@ -237,7 +237,7 @@ def _sanitise_precomiled_pdf(self, notification, precompiled_pdf):
|
||||
"sanitise_precomiled_pdf failed for notification: {}".format(notification.id)
|
||||
)
|
||||
self.retry(queue=QueueNames.RETRY)
|
||||
except self.MaxRetriesExceededError:
|
||||
except MaxRetriesExceededError:
|
||||
current_app.logger.exception(
|
||||
"RETRY FAILED: sanitise_precomiled_pdf failed for notification {}".format(notification.id),
|
||||
)
|
||||
|
||||
@@ -90,16 +90,6 @@ def upload_letter_pdf(notification, pdf_data, precompiled=False):
|
||||
return upload_file_name
|
||||
|
||||
|
||||
def move_scanned_pdf_to_test_or_live_pdf_bucket(source_filename, is_test_letter=False):
|
||||
source_bucket_name = current_app.config['LETTERS_SCAN_BUCKET_NAME']
|
||||
target_bucket_config = 'TEST_LETTERS_BUCKET_NAME' if is_test_letter else 'LETTERS_PDF_BUCKET_NAME'
|
||||
target_bucket_name = current_app.config[target_bucket_config]
|
||||
|
||||
target_filename = get_folder_name(datetime.utcnow(), is_test_letter) + source_filename
|
||||
|
||||
_move_s3_object(source_bucket_name, source_filename, target_bucket_name, target_filename)
|
||||
|
||||
|
||||
def move_failed_pdf(source_filename, scan_error_type):
|
||||
scan_bucket = current_app.config['LETTERS_SCAN_BUCKET_NAME']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user