def cancel_letter_job(service_id, job_id): job = dao_get_job_by_service_id_and_job_id(service_id, job_id) can_we_cancel, errors = can_letter_job_be_cancelled(job) if can_we_cancel: data = dao_cancel_letter_job(job) return jsonify(data), 200 else: return jsonify(message=errors), 400
def test_dao_cancel_letter_job_cancels_job_and_returns_number_of_cancelled_notifications( sample_letter_template ): job = create_job(template=sample_letter_template, notification_count=1, job_status='finished') notification = create_notification(template=job.template, job=job, status='created') result = dao_cancel_letter_job(job) assert result == 1 assert notification.status == 'cancelled' assert job.job_status == 'cancelled'