From e9e5f8d5c0e6589cbe4e57767f18d75df14b5ab7 Mon Sep 17 00:00:00 2001 From: stvnrlly Date: Mon, 6 Feb 2023 16:13:31 -0500 Subject: [PATCH] test cleaning for the current state of things --- app/celery/reporting_tasks.py | 2 +- app/dao/notifications_dao.py | 3 --- app/dao/templates_dao.py | 10 +--------- app/letters/rest.py | 5 +---- app/service/rest.py | 1 - app/v2/notifications/post_notifications.py | 4 ---- tests/app/celery/test_nightly_tasks.py | 2 +- tests/app/celery/test_research_mode_tasks.py | 1 - tests/app/celery/test_tasks.py | 3 --- tests/app/template/test_rest.py | 13 +------------ 10 files changed, 5 insertions(+), 39 deletions(-) diff --git a/app/celery/reporting_tasks.py b/app/celery/reporting_tasks.py index 9c79b6ca0..123eb8ced 100644 --- a/app/celery/reporting_tasks.py +++ b/app/celery/reporting_tasks.py @@ -86,7 +86,7 @@ def create_nightly_notification_status(): yesterday = convert_utc_to_local_timezone(datetime.utcnow()).date() - timedelta(days=1) for notification_type in [SMS_TYPE, EMAIL_TYPE]: - days = 4 + days = 4 for i in range(days): process_day = yesterday - timedelta(days=i) diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 2fee15805..0ccb6e03b 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -1,6 +1,5 @@ from datetime import datetime, timedelta -from botocore.exceptions import ClientError from flask import current_app from notifications_utils.international_billing_rates import ( INTERNATIONAL_BILLING_RATES, @@ -20,7 +19,6 @@ from werkzeug.datastructures import MultiDict from app import create_uuid, db from app.dao.dao_utils import autocommit -from app.letters.utils import LetterPDFNotFound, find_letter_pdf_in_s3 from app.models import ( EMAIL_TYPE, KEY_TYPE_NORMAL, @@ -32,7 +30,6 @@ from app.models import ( NOTIFICATION_PERMANENT_FAILURE, NOTIFICATION_SENDING, NOTIFICATION_SENT, - NOTIFICATION_STATUS_TYPES_COMPLETED, NOTIFICATION_TEMPORARY_FAILURE, SMS_TYPE, FactNotificationStatus, diff --git a/app/dao/templates_dao.py b/app/dao/templates_dao.py index dc586d26a..1b6d346d3 100644 --- a/app/dao/templates_dao.py +++ b/app/dao/templates_dao.py @@ -1,19 +1,11 @@ import uuid from datetime import datetime -from flask import current_app from sqlalchemy import asc, desc from app import db from app.dao.dao_utils import VersionOptions, autocommit, version_class -from app.dao.users_dao import get_user_by_id -from app.models import ( - LETTER_TYPE, - SECOND_CLASS, - Template, - TemplateHistory, - TemplateRedacted, -) +from app.models import Template, TemplateHistory, TemplateRedacted @autocommit diff --git a/app/letters/rest.py b/app/letters/rest.py index 7ce5c4d53..894f0b331 100644 --- a/app/letters/rest.py +++ b/app/letters/rest.py @@ -1,8 +1,5 @@ -from flask import Blueprint, jsonify, request +from flask import Blueprint -from app.config import QueueNames -from app.letters.letter_schemas import letter_references -from app.schema_validation import validate from app.v2.errors import register_errors letter_job = Blueprint("letter-job", __name__) diff --git a/app/service/rest.py b/app/service/rest.py index 33c2d7262..d097398f3 100644 --- a/app/service/rest.py +++ b/app/service/rest.py @@ -123,7 +123,6 @@ from app.schemas import ( ) from app.service import statistics from app.service.send_notification import send_one_off_notification -from app.service.send_pdf_letter_schema import send_pdf_letter_request from app.service.sender import send_notification_to_service_users from app.service.service_contact_list_schema import ( create_service_contact_list_schema, diff --git a/app/v2/notifications/post_notifications.py b/app/v2/notifications/post_notifications.py index d41d676eb..9ad2ddbff 100644 --- a/app/v2/notifications/post_notifications.py +++ b/app/v2/notifications/post_notifications.py @@ -25,7 +25,6 @@ from app.models import ( KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST, - LETTER_TYPE, NOTIFICATION_CREATED, NOTIFICATION_DELIVERED, NOTIFICATION_PENDING_VIRUS_CHECK, @@ -59,12 +58,10 @@ from app.v2.errors import BadRequestError from app.v2.notifications import v2_notification_blueprint from app.v2.notifications.create_response import ( create_post_email_response_from_notification, - create_post_letter_response_from_notification, create_post_sms_response_from_notification, ) from app.v2.notifications.notification_schemas import ( post_email_request, - post_letter_request, post_sms_request, ) from app.v2.utils import get_valid_json @@ -136,7 +133,6 @@ def post_notification(notification_type): reply_to = get_reply_to_text(notification_type, form, template) - notification = process_sms_or_email_notification( form=form, notification_type=notification_type, diff --git a/tests/app/celery/test_nightly_tasks.py b/tests/app/celery/test_nightly_tasks.py index 2c003876a..dcfa1d3e4 100644 --- a/tests/app/celery/test_nightly_tasks.py +++ b/tests/app/celery/test_nightly_tasks.py @@ -15,7 +15,7 @@ from app.celery.nightly_tasks import ( save_daily_notification_processing_time, timeout_notifications, ) -from app.models import EMAIL_TYPE, LETTER_TYPE, SMS_TYPE, FactProcessingTime +from app.models import EMAIL_TYPE, SMS_TYPE, FactProcessingTime from tests.app.db import ( create_job, create_notification, diff --git a/tests/app/celery/test_research_mode_tasks.py b/tests/app/celery/test_research_mode_tasks.py index 57ad2507d..5bc401d54 100644 --- a/tests/app/celery/test_research_mode_tasks.py +++ b/tests/app/celery/test_research_mode_tasks.py @@ -6,7 +6,6 @@ from flask import json from app.celery.research_mode_tasks import ( HTTPError, - create_fake_letter_response_file, send_email_response, send_sms_response, ses_notification_callback, diff --git a/tests/app/celery/test_tasks.py b/tests/app/celery/test_tasks.py index 6cc90c836..745fba234 100644 --- a/tests/app/celery/test_tasks.py +++ b/tests/app/celery/test_tasks.py @@ -44,8 +44,6 @@ from app.models import ( SMS_TYPE, Job, Notification, - NotificationHistory, - ReturnedLetter, ) from app.serialised_models import SerialisedService, SerialisedTemplate from app.utils import DATETIME_FORMAT @@ -57,7 +55,6 @@ from tests.app.db import ( create_job, create_letter_contact, create_notification, - create_notification_history, create_reply_to_email, create_service, create_service_inbound_api, diff --git a/tests/app/template/test_rest.py b/tests/app/template/test_rest.py index b1c555f4d..f320afd5b 100644 --- a/tests/app/template/test_rest.py +++ b/tests/app/template/test_rest.py @@ -1,23 +1,14 @@ -import base64 import json import random import string import uuid from datetime import datetime, timedelta -import botocore import pytest -import requests_mock from freezegun import freeze_time from notifications_utils import SMS_CHAR_COUNT_LIMIT -from PyPDF2.errors import PdfReadError -from app.dao.templates_dao import ( - dao_get_template_by_id, - dao_get_template_versions, - dao_redact_template, - dao_update_template, -) +from app.dao.templates_dao import dao_get_template_by_id, dao_redact_template from app.models import ( EMAIL_TYPE, LETTER_TYPE, @@ -28,12 +19,10 @@ from app.models import ( from tests import create_admin_authorization_header from tests.app.db import ( create_letter_contact, - create_notification, create_service, create_template, create_template_folder, ) -from tests.conftest import set_config_values @pytest.mark.parametrize('template_type, subject', [