diff --git a/inventory_provider/__init__.py b/inventory_provider/__init__.py index 5de6a3115f4d1af8539195df786e39e9e0d1906b..485cf81ce4288c4d353520c2245104d0fe839e2d 100644 --- a/inventory_provider/__init__.py +++ b/inventory_provider/__init__.py @@ -17,6 +17,9 @@ def create_app(): app = Flask(__name__) app.secret_key = "super secret session key" + from inventory_provider.routes import default + app.register_blueprint(default.routes, url_prefix='/') + from inventory_provider.routes import data app.register_blueprint(data.routes, url_prefix='/data') diff --git a/inventory_provider/routes/data.py b/inventory_provider/routes/data.py index 85fb5f010cdbf51324bcf02d068bb2c36214ac8b..7d39d0052aa3b2657e2968324a28081a4c53fd2d 100644 --- a/inventory_provider/routes/data.py +++ b/inventory_provider/routes/data.py @@ -10,20 +10,6 @@ from inventory_provider.routes import common routes = Blueprint("inventory-data-query-routes", __name__) -API_VERSION = '0.1' - - -@routes.route("/version", methods=['GET', 'POST']) -@common.require_accepts_json -def version(): - return Response( - json.dumps({ - 'api': API_VERSION, - 'module': - pkg_resources.get_distribution('inventory_provider').version - }), - mimetype="application/json" - ) @routes.route("/routers", methods=['GET', 'POST']) diff --git a/inventory_provider/routes/default.py b/inventory_provider/routes/default.py new file mode 100644 index 0000000000000000000000000000000000000000..38bf3ea3b25e9ff2fccf568d512a2d5aad23b823 --- /dev/null +++ b/inventory_provider/routes/default.py @@ -0,0 +1,19 @@ +import json +import pkg_resources + +from flask import Blueprint, jsonify +from inventory_provider.routes import common + +routes = Blueprint("inventory-data-default-routes", __name__) + +API_VERSION = '0.1' + + +@routes.route("/version", methods=['GET', 'POST']) +@common.require_accepts_json +def version(): + return jsonify({ + 'api': API_VERSION, + 'module': + pkg_resources.get_distribution('inventory_provider').version + }) diff --git a/test/test_general_routes.py b/test/test_general_routes.py index 7f51fccad0f0c3c174d6e1a3aee4ac7fff0549ed..f7c4dda49f2a1711d3b38104af3df1ec1f698775 100644 --- a/test/test_general_routes.py +++ b/test/test_general_routes.py @@ -26,7 +26,7 @@ def test_version_request(client): } rv = client.post( - "data/version", + "version", headers=DEFAULT_REQUEST_HEADERS) assert rv.status_code == 200 jsonschema.validate(