mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Cancel job if the service is inactive.
Update the PermissionsDao.get_permissions_by_user_id to only return permissions for active services, this will make the admin app return a 403 if someone (otherthan platform admin) tries to look at an inactive service. Removed the active flag in sample_service the dao_create_service overiddes this attribute.
This commit is contained in:
@@ -923,6 +923,22 @@ def test_persist_letter_saves_letter_to_database(sample_letter_job, mocker):
|
||||
assert notification_db.personalisation == personalisation
|
||||
|
||||
|
||||
def test_should_cancel_job_if_service_is_inactive(sample_service,
|
||||
sample_job,
|
||||
mocker):
|
||||
sample_service.active = False
|
||||
|
||||
mocker.patch('app.celery.tasks.s3.get_job_from_s3')
|
||||
mocker.patch('app.celery.tasks.process_row')
|
||||
|
||||
process_job(sample_job.id)
|
||||
|
||||
job = jobs_dao.dao_get_job_by_id(sample_job.id)
|
||||
assert job.job_status == 'cancelled'
|
||||
s3.get_job_from_s3.assert_not_called()
|
||||
tasks.process_row.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('template_type, expected_class', [
|
||||
(SMS_TYPE, SMSMessageTemplate),
|
||||
(EMAIL_TYPE, WithSubjectTemplate),
|
||||
|
||||
Reference in New Issue
Block a user