Update how pending virus check Zendesk tickets are created

This updates the tickets that are created when the
`check_if_letters_still_pending_virus_check` scheduled task detects
letters in the `pending-virus-check` state.
This commit is contained in:
Katie Smith
2021-09-23 15:05:07 +01:00
parent 9ff0ca0363
commit b114dadcae
2 changed files with 25 additions and 8 deletions

View File

@@ -1,10 +1,13 @@
from collections import namedtuple
from datetime import datetime, timedelta
from unittest import mock
from unittest.mock import call
from unittest.mock import ANY, call
import pytest
from freezegun import freeze_time
from notifications_utils.clients.zendesk.zendesk_client import (
NotifySupportTicket,
)
from app.celery import scheduled_tasks
from app.celery.scheduled_tasks import (
@@ -364,7 +367,11 @@ def test_check_job_status_task_does_not_raise_error(sample_template):
@freeze_time("2019-05-30 14:00:00")
def test_check_if_letters_still_pending_virus_check(mocker, sample_letter_template):
mock_logger = mocker.patch('app.celery.tasks.current_app.logger.error')
mock_create_ticket = mocker.patch('app.celery.nightly_tasks.zendesk_client.create_ticket')
mock_create_ticket = mocker.spy(NotifySupportTicket, '__init__')
mock_send_ticket_to_zendesk = mocker.patch(
'app.celery.scheduled_tasks.zendesk_client.send_ticket_to_zendesk',
autospec=True,
)
create_notification(template=sample_letter_template,
status=NOTIFICATION_PENDING_VIRUS_CHECK,
@@ -391,11 +398,15 @@ def test_check_if_letters_still_pending_virus_check(mocker, sample_letter_templa
Notifications: {}""".format(id_references)
mock_logger.assert_called_once_with(message)
mock_create_ticket.assert_called_with(
message=message,
mock_create_ticket.assert_called_once_with(
ANY,
subject='[test] Letters still pending virus check',
ticket_type='incident'
message=message,
ticket_type='incident',
technical_ticket=True,
ticket_categories=['notify_letters']
)
mock_send_ticket_to_zendesk.assert_called_once()
@freeze_time("2019-05-30 14:00:00")