update tests to reflect new code

also change jobs.py to filter out test jobs (since we dont need to see em)
and to use the new statuses filter rather than filtering on front end
This commit is contained in:
Leo Hemsted
2016-10-05 17:45:04 +01:00
parent 441a2717f2
commit aa458a15da
6 changed files with 53 additions and 32 deletions

View File

@@ -902,7 +902,10 @@ def mock_get_job_in_progress(mocker, api_user_active):
@pytest.fixture(scope='function')
def mock_get_jobs(mocker, api_user_active):
def _get_jobs(service_id, limit_days=None, statuses=None):
return {"data": [
if statuses is None:
statuses = ['', 'scheduled', 'pending', 'cancelled']
jobs = [
job_json(
service_id,
api_user_active,
@@ -911,17 +914,17 @@ def mock_get_jobs(mocker, api_user_active):
job_status=job_status
)
for filename, scheduled_for, job_status in (
("Test message", '', ''),
("Test message", '2016-01-01 11:09:00.061258', 'scheduled'),
("export 1/1/2016.xls", '', ''),
("Test message", '', 'finished'),
("export 1/1/2016.xls", '', 'finished'),
("all email addresses.xlsx", '', 'pending'),
("applicants.ods", '', ''),
("thisisatest.csv", '', ''),
("applicants.ods", '', 'finished'),
("thisisatest.csv", '', 'finished'),
("send_me_later.csv", '2016-01-01 11:09:00.061258', 'scheduled'),
("even_later.csv", '2016-01-01 23:09:00.061258', 'scheduled'),
("full_of_regret.csv", '2016-01-01 23:09:00.061258', 'cancelled')
)
]}
]
return {"data": [job for job in jobs if job['job_status'] in statuses]}
return mocker.patch('app.job_api_client.get_jobs', side_effect=_get_jobs)