Merge pull request #1761 from alphagov/create-virus-scan-statuses

Add new virus scan statuses
This commit is contained in:
Katie Smith
2018-03-13 13:09:05 +00:00
committed by GitHub
4 changed files with 38 additions and 3 deletions

View File

@@ -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))

View File

@@ -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')")

View File

@@ -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):

View File

@@ -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