mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 17:45:41 -04:00
Removed update_job endpoint because it is not being used
This commit is contained in:
@@ -7,8 +7,7 @@ from flask import (
|
|||||||
from app.dao.jobs_dao import (
|
from app.dao.jobs_dao import (
|
||||||
dao_create_job,
|
dao_create_job,
|
||||||
dao_get_job_by_service_id_and_job_id,
|
dao_get_job_by_service_id_and_job_id,
|
||||||
dao_get_jobs_by_service_id,
|
dao_get_jobs_by_service_id
|
||||||
dao_update_job
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from app.dao.services_dao import (
|
from app.dao.services_dao import (
|
||||||
@@ -57,16 +56,3 @@ def create_job(service_id):
|
|||||||
dao_create_job(job)
|
dao_create_job(job)
|
||||||
process_job.apply_async([str(job.id)], queue="process-job")
|
process_job.apply_async([str(job.id)], queue="process-job")
|
||||||
return jsonify(data=job_schema.dump(job).data), 201
|
return jsonify(data=job_schema.dump(job).data), 201
|
||||||
|
|
||||||
|
|
||||||
@job.route('/<job_id>', 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
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class CreatedBySchema(ma.Schema):
|
|||||||
if not isinstance(data.get('created_by'), models.User):
|
if not isinstance(data.get('created_by'), models.User):
|
||||||
created_by = models.User.query.filter_by(id=data.get('created_by')).one()
|
created_by = models.User.query.filter_by(id=data.get('created_by')).one()
|
||||||
except:
|
except:
|
||||||
raise ValidationError('Invalid template created_by: {}'.format(data))
|
raise ValidationError('Invalid created_by: {}'.format(data))
|
||||||
|
|
||||||
@post_load
|
@post_load
|
||||||
def format_created_by(self, item):
|
def format_created_by(self, item):
|
||||||
|
|||||||
@@ -180,35 +180,6 @@ def test_create_job_returns_404_if_missing_service(notify_api, sample_template,
|
|||||||
assert resp_json['message'] == 'No result found'
|
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):
|
def _setup_jobs(notify_db, notify_db_session, template, number_of_jobs=5):
|
||||||
for i in range(number_of_jobs):
|
for i in range(number_of_jobs):
|
||||||
create_job(
|
create_job(
|
||||||
|
|||||||
Reference in New Issue
Block a user