Remove join to Template table.

Fix typo in unit test.
This commit is contained in:
Rebecca Law
2017-06-13 11:55:14 +01:00
parent 4fefec6aa3
commit a83e744c68
2 changed files with 7 additions and 10 deletions

View File

@@ -149,9 +149,8 @@ def dao_get_job_statistics_for_job(service_id, job_id):
query = Job.query.join( query = Job.query.join(
JobStatistics, Job.id == JobStatistics.job_id JobStatistics, Job.id == JobStatistics.job_id
).filter( ).filter(
Job.id == job_id Job.id == job_id,
).join( Job.service_id == service_id
Template, Template.id == Job.template_id and Template.version == Job.template_version
).add_columns( ).add_columns(
JobStatistics.job_id, JobStatistics.job_id,
Job.original_file_name, Job.original_file_name,
@@ -165,8 +164,6 @@ def dao_get_job_statistics_for_job(service_id, job_id):
JobStatistics.sent, JobStatistics.sent,
JobStatistics.delivered, JobStatistics.delivered,
JobStatistics.failed JobStatistics.failed
).filter(
Job.service_id == service_id
) )
return query.one() return query.one()

View File

@@ -796,8 +796,9 @@ def test_get_jobs_raises_for_bad_limit_days(client, sample_service):
query_string={'limit_days': 'bad_number'}, query_string={'limit_days': 'bad_number'},
headers=[auth_header]) headers=[auth_header])
assert response.status_code == 400 assert response.status_code == 400
assert response.get_data(as_text=True) == '{\n "message": {\n "limit_days": [\n ' \ resp_json = json.loads(response.get_data(as_text=True))
'"bad_number is not an integer"\n ]\n },\n "result": "error"\n}' assert resp_json["result"] == "error"
assert resp_json["message"] == {'limit_days': ['bad_number is not an integer']}
def test_parse_status_turns_comma_sep_strings_into_list(): def test_parse_status_turns_comma_sep_strings_into_list():
@@ -831,8 +832,7 @@ def test_get_job_stats_by_service_id_and_job_id(client, sample_job):
def test_get_job_stats_with_invalid_job_id_returns404(client, sample_template): def test_get_job_stats_with_invalid_job_id_returns404(client, sample_template):
service_id = sample_template.service.id path = '/service/{}/job/job-stats{}'.format(sample_template.service.id, uuid.uuid4())
path = '/service/{}/job/job-=stats{}'.format(service_id, "bad-id")
auth_header = create_authorization_header() auth_header = create_authorization_header()
response = client.get(path, headers=[auth_header]) response = client.get(path, headers=[auth_header])
assert response.status_code == 404 assert response.status_code == 404
@@ -842,7 +842,7 @@ def test_get_job_stats_with_invalid_job_id_returns404(client, sample_template):
def test_get_job_stats_with_invalid_service_id_returns404(client, sample_job): def test_get_job_stats_with_invalid_service_id_returns404(client, sample_job):
path = '/service/{}/job/job-=stats{}'.format(uuid.uuid4(), sample_job.id) path = '/service/{}/job/job-stats{}'.format(uuid.uuid4(), sample_job.id)
auth_header = create_authorization_header() auth_header = create_authorization_header()
response = client.get(path, headers=[auth_header]) response = client.get(path, headers=[auth_header])
assert response.status_code == 404 assert response.status_code == 404