Some more tests around edge cases

This commit is contained in:
Martyn Inglis
2016-03-09 11:35:12 +00:00
parent 14d621d243
commit 61af70a392
3 changed files with 30 additions and 3 deletions

View File

@@ -80,6 +80,33 @@ def test_should_not_process_sms_job_if_would_exceed_send_limits(notify_db, notif
tasks.send_email.apply_async.assert_not_called
@freeze_time("2016-01-01 11:09:00.061258")
def test_should_process_sms_job_if_exactly_on_send_limits(notify_db, notify_db_session, mocker):
service = sample_service(notify_db, notify_db_session, limit=10)
template = sample_email_template(notify_db, notify_db_session, service=service)
job = sample_job(notify_db, notify_db_session, service=service, template=template)
mocker.patch('app.celery.tasks.s3.get_job_from_s3', return_value=load_example_csv('multiple_email'))
mocker.patch('app.celery.tasks.send_email.apply_async')
mocker.patch('app.encryption.encrypt', return_value="something_encrypted")
mocker.patch('app.celery.tasks.create_uuid', return_value="uuid")
process_job(job.id)
s3.get_job_from_s3.assert_called_once_with(job.bucket_name, job.id)
job = jobs_dao.dao_get_job_by_id(job.id)
assert job.status == 'finished'
tasks.send_email.apply_async.assert_called_with(
(str(job.service_id),
"uuid",
job.template.subject,
"{}@{}".format(job.service.email_from, "test.notify.com"),
"something_encrypted",
"2016-01-01T11:09:00.061258"),
queue="bulk-email"
)
def test_should_not_create_send_task_for_empty_file(sample_job, mocker):
mocker.patch('app.celery.tasks.s3.get_job_from_s3', return_value=load_example_csv('empty'))
mocker.patch('app.celery.tasks.send_sms.apply_async')