From 3f7bae3428341cdb738079198068919b7c42b1b0 Mon Sep 17 00:00:00 2001 From: Rebecca Law Date: Wed, 27 Apr 2016 09:46:45 +0100 Subject: [PATCH] Removed update_job endpoint because it is not being used --- app/job/rest.py | 16 +--------------- app/schemas.py | 2 +- tests/app/job/test_rest.py | 29 ----------------------------- 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/app/job/rest.py b/app/job/rest.py index 59eda8666..1e658ccaf 100644 --- a/app/job/rest.py +++ b/app/job/rest.py @@ -7,8 +7,7 @@ from flask import ( from app.dao.jobs_dao import ( dao_create_job, dao_get_job_by_service_id_and_job_id, - dao_get_jobs_by_service_id, - dao_update_job + dao_get_jobs_by_service_id ) from app.dao.services_dao import ( @@ -57,16 +56,3 @@ def create_job(service_id): dao_create_job(job) process_job.apply_async([str(job.id)], queue="process-job") return jsonify(data=job_schema.dump(job).data), 201 - - -@job.route('/', methods=['POST']) -def update_job(service_id, job_id): - fetched_job = dao_get_job_by_service_id_and_job_id(service_id, job_id) - current_data = dict(job_schema.dump(fetched_job).data.items()) - current_data.update(request.get_json()) - - update_dict, errors = job_schema.load(current_data) - if errors: - return jsonify(result="error", message=errors), 400 - dao_update_job(update_dict) - return jsonify(data=job_schema.dump(update_dict).data), 200 diff --git a/app/schemas.py b/app/schemas.py index 9818e6a97..958efa45d 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -58,7 +58,7 @@ class CreatedBySchema(ma.Schema): if not isinstance(data.get('created_by'), models.User): created_by = models.User.query.filter_by(id=data.get('created_by')).one() except: - raise ValidationError('Invalid template created_by: {}'.format(data)) + raise ValidationError('Invalid created_by: {}'.format(data)) @post_load def format_created_by(self, item): diff --git a/tests/app/job/test_rest.py b/tests/app/job/test_rest.py index fffa384cd..56bebe51d 100644 --- a/tests/app/job/test_rest.py +++ b/tests/app/job/test_rest.py @@ -180,35 +180,6 @@ def test_create_job_returns_404_if_missing_service(notify_api, sample_template, assert resp_json['message'] == 'No result found' -def test_get_update_job(notify_api, sample_job): - assert sample_job.status == 'pending' - - job_id = str(sample_job.id) - service_id = str(sample_job.service.id) - - update_data = { - 'status': 'in progress' - } - - with notify_api.test_request_context(): - with notify_api.test_client() as client: - path = '/service/{}/job/{}'.format(service_id, job_id) - - auth_header = create_authorization_header( - service_id=service_id, - path=path, - method='POST', - request_body=json.dumps(update_data)) - - headers = [('Content-Type', 'application/json'), auth_header] - - response = client.post(path, headers=headers, data=json.dumps(update_data)) - - resp_json = json.loads(response.get_data(as_text=True)) - assert response.status_code == 200 - assert resp_json['data']['status'] == 'in progress' - - def _setup_jobs(notify_db, notify_db_session, template, number_of_jobs=5): for i in range(number_of_jobs): create_job(