mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-07 06:18:26 -04:00
Update send letter jobs to return json
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
from flask import request
|
from flask import request
|
||||||
|
|
||||||
@@ -14,10 +16,12 @@ register_errors(letter_job)
|
|||||||
|
|
||||||
@letter_job.route('/send-letter-jobs', methods=['POST'])
|
@letter_job.route('/send-letter-jobs', methods=['POST'])
|
||||||
def send_letter_jobs():
|
def send_letter_jobs():
|
||||||
job_ids = validate(request.get_json(), letter_job_ids)
|
req_json = request.get_json()
|
||||||
|
job_ids = validate(req_json, letter_job_ids)
|
||||||
|
|
||||||
notify_celery.send_task(name="send-files-to-dvla", args=(job_ids['job_ids'],), queue="process-ftp")
|
notify_celery.send_task(name="send-files-to-dvla", args=(job_ids['job_ids'],), queue="process-ftp")
|
||||||
|
|
||||||
return "Task created to send files to DVLA"
|
return jsonify(data={"response": "Task created to send files to DVLA"}), 200
|
||||||
|
|
||||||
|
|
||||||
@letter_job.route('/letter-jobs', methods=['GET'])
|
@letter_job.route('/letter-jobs', methods=['GET'])
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ def test_send_letter_jobs(client, mocker):
|
|||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.get_data(as_text=True) == "Task created to send files to DVLA"
|
assert json.loads(response.get_data())['data'] == {'response': "Task created to send files to DVLA"}
|
||||||
|
|
||||||
mock_celery.assert_called_once_with(name="send-files-to-dvla",
|
mock_celery.assert_called_once_with(name="send-files-to-dvla",
|
||||||
args=(job_ids['job_ids'],),
|
args=(job_ids['job_ids'],),
|
||||||
|
|||||||
Reference in New Issue
Block a user