filter out test jobs from the GET /service/{}/job endpoint

this is so that the filtering, which we do on the admin side, is applied
before pagination - so that the pages returned are all valid displayable
jobs. unfortunately this means that another config value has to be copied
to the server side but it's not the end of the world
This commit is contained in:
Leo Hemsted
2016-10-11 14:30:40 +01:00
parent 153e9c3f3a
commit d8467bfc3c
4 changed files with 22 additions and 3 deletions

View File

@@ -265,7 +265,8 @@ def sample_job(notify_db,
created_at=None,
job_status='pending',
scheduled_for=None,
processing_started=None):
processing_started=None,
original_file_name='some.csv'):
if service is None:
service = sample_service(notify_db, notify_db_session)
if template is None:
@@ -277,7 +278,7 @@ def sample_job(notify_db,
'service': service,
'template_id': template.id,
'template_version': template.version,
'original_file_name': 'some.csv',
'original_file_name': original_file_name,
'notification_count': notification_count,
'created_at': created_at or datetime.utcnow(),
'created_by': service.created_by,

View File

@@ -300,3 +300,16 @@ def test_get_jobs_for_service_is_paginated(notify_db, notify_db_session, sample_
assert len(res.items) == 2
assert res.items[0].created_at == datetime(2015, 1, 1, 8)
assert res.items[1].created_at == datetime(2015, 1, 1, 7)
def test_get_jobs_for_service_doesnt_return_test_messages(notify_db, notify_db_session, sample_template, sample_job):
test_job = create_job(
notify_db,
notify_db_session,
sample_template.service,
sample_template,
original_file_name='Test message')
jobs = dao_get_jobs_by_service_id(sample_job.service_id).items
assert jobs == [sample_job]