diff --git a/app/models.py b/app/models.py index ab587a745..e78fd18ea 100644 --- a/app/models.py +++ b/app/models.py @@ -1003,11 +1003,14 @@ NOTIFICATION_FAILED = 'failed' NOTIFICATION_TECHNICAL_FAILURE = 'technical-failure' NOTIFICATION_TEMPORARY_FAILURE = 'temporary-failure' NOTIFICATION_PERMANENT_FAILURE = 'permanent-failure' +NOTIFICATION_PENDING_VIRUS_CHECK = 'pending-virus-check' +NOTIFICATION_VIRUS_SCAN_FAILED = 'virus-scan-failed' NOTIFICATION_STATUS_TYPES_FAILED = [ NOTIFICATION_TECHNICAL_FAILURE, NOTIFICATION_TEMPORARY_FAILURE, NOTIFICATION_PERMANENT_FAILURE, + NOTIFICATION_VIRUS_SCAN_FAILED, ] NOTIFICATION_STATUS_TYPES_COMPLETED = [ @@ -1044,6 +1047,8 @@ NOTIFICATION_STATUS_TYPES = [ NOTIFICATION_TECHNICAL_FAILURE, NOTIFICATION_TEMPORARY_FAILURE, NOTIFICATION_PERMANENT_FAILURE, + NOTIFICATION_PENDING_VIRUS_CHECK, + NOTIFICATION_VIRUS_SCAN_FAILED, ] NOTIFICATION_STATUS_TYPES_NON_BILLABLE = list(set(NOTIFICATION_STATUS_TYPES) - set(NOTIFICATION_STATUS_TYPES_BILLABLE)) diff --git a/migrations/versions/0177_add_virus_scan_statuses.py b/migrations/versions/0177_add_virus_scan_statuses.py new file mode 100644 index 000000000..013df7e24 --- /dev/null +++ b/migrations/versions/0177_add_virus_scan_statuses.py @@ -0,0 +1,27 @@ +""" + +Revision ID: 0177_add_virus_scan_statuses +Revises: 0176_alter_billing_columns +Create Date: 2018-02-21 14:05:04.448977 + +""" +from alembic import op + + +revision = '0176_alter_billing_columns' +down_revision = '0175_drop_job_statistics_table' + + +def upgrade(): + op.execute("INSERT INTO notification_status_types (name) VALUES ('pending-virus-check')") + op.execute("INSERT INTO notification_status_types (name) VALUES ('virus-scan-failed')") + + +def downgrade(): + op.execute("UPDATE notifications SET notification_status = 'created' WHERE notification_status = 'pending-virus-check'") + op.execute("UPDATE notification_history SET notification_status = 'created' WHERE notification_status = 'pending-virus-check'") + + op.execute("UPDATE notifications SET notification_status = 'permanent-failure' WHERE notification_status = 'virus-scan-failed'") + op.execute("UPDATE notification_history SET notification_status = 'permanent-failure' WHERE notification_status = 'virus-scan-failed'") + + op.execute("DELETE FROM notification_status_types WHERE name in ('pending-virus-check', 'virus-scan-failed')") diff --git a/tests/app/v2/notifications/test_get_notifications.py b/tests/app/v2/notifications/test_get_notifications.py index 0e6a3d911..f2da004f7 100644 --- a/tests/app/v2/notifications/test_get_notifications.py +++ b/tests/app/v2/notifications/test_get_notifications.py @@ -422,7 +422,8 @@ def test_get_all_notifications_filter_by_status_invalid_status(client, sample_no assert json_response['status_code'] == 400 assert len(json_response['errors']) == 1 assert json_response['errors'][0]['message'] == "status elephant is not one of [created, sending, sent, " \ - "delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, accepted, received]" + "delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, pending-virus-check, " \ + "virus-scan-failed, accepted, received]" def test_get_all_notifications_filter_by_multiple_statuses(client, sample_template): diff --git a/tests/app/v2/notifications/test_notification_schemas.py b/tests/app/v2/notifications/test_notification_schemas.py index 7506da990..201f35542 100644 --- a/tests/app/v2/notifications/test_notification_schemas.py +++ b/tests/app/v2/notifications/test_notification_schemas.py @@ -43,7 +43,8 @@ def test_get_notifications_request_invalid_statuses( ): partial_error_status = "is not one of " \ "[created, sending, sent, delivered, pending, failed, " \ - "technical-failure, temporary-failure, permanent-failure, accepted, received]" + "technical-failure, temporary-failure, permanent-failure, pending-virus-check, " \ + "virus-scan-failed, accepted, received]" with pytest.raises(ValidationError) as e: validate({'status': invalid_statuses + valid_statuses}, get_notifications_request) @@ -90,7 +91,8 @@ def test_get_notifications_request_invalid_statuses_and_template_types(): error_messages = [error['message'] for error in errors] for invalid_status in ["elephant", "giraffe"]: assert "status {} is not one of [created, sending, sent, delivered, " \ - "pending, failed, technical-failure, temporary-failure, permanent-failure, accepted, received]".format( + "pending, failed, technical-failure, temporary-failure, permanent-failure, " \ + "pending-virus-check, virus-scan-failed, accepted, received]".format( invalid_status ) in error_messages