mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-01 13:21:44 -05:00
add GET /dvla_organisation endpoint
This commit is contained in:
@@ -90,6 +90,7 @@ def register_blueprint(application):
|
||||
from app.provider_details.rest import provider_details as provider_details_blueprint
|
||||
from app.spec.rest import spec as spec_blueprint
|
||||
from app.organisation.rest import organisation_blueprint
|
||||
from app.dvla_organisation.rest import dvla_organisation_blueprint
|
||||
from app.delivery.rest import delivery_blueprint
|
||||
from app.notifications.receive_notifications import receive_notifications_blueprint
|
||||
from app.notifications.notifications_ses_callback import ses_callback_blueprint
|
||||
@@ -148,6 +149,9 @@ def register_blueprint(application):
|
||||
organisation_blueprint.before_request(requires_admin_auth)
|
||||
application.register_blueprint(organisation_blueprint, url_prefix='/organisation')
|
||||
|
||||
dvla_organisation_blueprint.before_request(requires_admin_auth)
|
||||
application.register_blueprint(dvla_organisation_blueprint, url_prefix='/dvla_organisations')
|
||||
|
||||
letter_job.before_request(requires_admin_auth)
|
||||
application.register_blueprint(letter_job)
|
||||
|
||||
|
||||
5
app/dao/dvla_organisation_dao.py
Normal file
5
app/dao/dvla_organisation_dao.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from app.models import DVLAOrganisation
|
||||
|
||||
|
||||
def dao_get_dvla_organisations():
|
||||
return DVLAOrganisation.query.all()
|
||||
0
app/dvla_organisation/__init__.py
Normal file
0
app/dvla_organisation/__init__.py
Normal file
14
app/dvla_organisation/rest.py
Normal file
14
app/dvla_organisation/rest.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from flask import Blueprint, jsonify
|
||||
|
||||
from app.dao.dvla_organisation_dao import dao_get_dvla_organisations
|
||||
from app.errors import register_errors
|
||||
|
||||
dvla_organisation_blueprint = Blueprint('dvla_organisation', __name__)
|
||||
register_errors(dvla_organisation_blueprint)
|
||||
|
||||
|
||||
@dvla_organisation_blueprint.route('', methods=['GET'])
|
||||
def get_dvla_organisations():
|
||||
return jsonify({
|
||||
org.id: org.name for org in dao_get_dvla_organisations()
|
||||
})
|
||||
0
tests/app/dvla_organisation/__init__.py
Normal file
0
tests/app/dvla_organisation/__init__.py
Normal file
13
tests/app/dvla_organisation/test_rest.py
Normal file
13
tests/app/dvla_organisation/test_rest.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from flask import json
|
||||
|
||||
from tests import create_authorization_header
|
||||
|
||||
|
||||
def test_get_dvla_organisations(client):
|
||||
auth_header = create_authorization_header()
|
||||
|
||||
response = client.get('/dvla_organisations', headers=[auth_header])
|
||||
|
||||
assert response.status_code == 200
|
||||
dvla_organisations = json.loads(response.get_data(as_text=True))
|
||||
assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}
|
||||
Reference in New Issue
Block a user