mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Added a check that the call is not using a test api key.
Removed the tests for trial mode service for the scheduled tasks and the process job. Having the validation in the POST notification and create job endpoint is enough. Updated the test_service_whitelist test because the order of the array is not gaurenteed.
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import uuid
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from functools import partial
|
||||
from unittest.mock import call, patch, PropertyMock
|
||||
@@ -41,9 +39,9 @@ from app.dao.provider_details_dao import (
|
||||
from app.models import (
|
||||
Service, Template,
|
||||
SMS_TYPE, LETTER_TYPE,
|
||||
JOB_STATUS_READY_TO_SEND, JOB_STATUS_ERROR,
|
||||
JOB_STATUS_READY_TO_SEND,
|
||||
MonthlyBilling)
|
||||
from app.utils import get_london_midnight_in_utc, convert_utc_to_bst
|
||||
from app.utils import get_london_midnight_in_utc
|
||||
from tests.app.db import create_notification, create_service, create_template, create_job, create_rate
|
||||
from tests.app.conftest import (
|
||||
sample_job as create_sample_job,
|
||||
@@ -694,42 +692,3 @@ def test_run_letter_jobs(client, mocker, sample_letter_template):
|
||||
mock_celery.assert_called_once_with(name=TaskNames.DVLA_FILES,
|
||||
args=(job_ids,),
|
||||
queue=QueueNames.PROCESS_FTP)
|
||||
|
||||
|
||||
def test_run_letter_jobs_in_trial_sets_job_to_error(client, mocker, sample_letter_template):
|
||||
sample_letter_template.service.restricted = True
|
||||
job = create_job(sample_letter_template)
|
||||
job_ids = [str(job.id)]
|
||||
mocker.patch(
|
||||
"app.celery.scheduled_tasks.dao_get_letter_job_ids_by_status",
|
||||
return_value=job_ids
|
||||
)
|
||||
mock_celery = mocker.patch("app.celery.tasks.notify_celery.send_task")
|
||||
|
||||
run_letter_jobs()
|
||||
|
||||
assert not mock_celery.called
|
||||
assert job.job_status == JOB_STATUS_ERROR
|
||||
|
||||
|
||||
def test_run_letter_jobs_in_trial_sets_job_to_error_and_process_live_services(
|
||||
client, mocker, sample_letter_template):
|
||||
live_job = create_job(sample_letter_template)
|
||||
|
||||
service = create_service(service_name="Sample service 2", restricted=True)
|
||||
template = create_template(service, template_type=LETTER_TYPE)
|
||||
trial_job = create_job(template)
|
||||
|
||||
job_ids = [str(live_job.id), str(trial_job.id)]
|
||||
mocker.patch(
|
||||
"app.celery.scheduled_tasks.dao_get_letter_job_ids_by_status",
|
||||
return_value=job_ids
|
||||
)
|
||||
mock_celery = mocker.patch("app.celery.tasks.notify_celery.send_task")
|
||||
|
||||
run_letter_jobs()
|
||||
|
||||
mock_celery.assert_called_once_with(name=TaskNames.DVLA_FILES,
|
||||
args=([str(live_job.id)],),
|
||||
queue=QueueNames.PROCESS_FTP)
|
||||
assert trial_job.job_status == JOB_STATUS_ERROR
|
||||
|
||||
@@ -1035,26 +1035,6 @@ def test_should_cancel_job_if_service_is_inactive(sample_service,
|
||||
mock_dvla_file_task.assert_not_called()
|
||||
|
||||
|
||||
def test_should_error_job_if_service_is_restricted_and_letter_template_type(
|
||||
sample_service,
|
||||
sample_letter_job,
|
||||
mocker
|
||||
):
|
||||
sample_service.restricted = True
|
||||
|
||||
mocker.patch('app.celery.tasks.s3.get_job_from_s3')
|
||||
mocker.patch('app.celery.tasks.process_row')
|
||||
mock_dvla_file_task = mocker.patch('app.celery.tasks.build_dvla_file')
|
||||
|
||||
process_job(sample_letter_job.id)
|
||||
|
||||
job = jobs_dao.dao_get_job_by_id(sample_letter_job.id)
|
||||
assert job.job_status == JOB_STATUS_ERROR
|
||||
s3.get_job_from_s3.assert_not_called()
|
||||
tasks.process_row.assert_not_called()
|
||||
mock_dvla_file_task.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('template_type, expected_class', [
|
||||
(SMS_TYPE, SMSMessageTemplate),
|
||||
(EMAIL_TYPE, WithSubjectTemplate),
|
||||
|
||||
Reference in New Issue
Block a user