Commit 4e71e7c3 authored by Sascha Herzinger's avatar Sascha Herzinger
Browse files

added new api call to check for backend version

parent c6272a2a
......@@ -60,11 +60,13 @@ from fractalis.celeryapp import make_celery, register_tasks # noqa
celery = make_celery(app)
# register blueprints
from import analytics_blueprint # noqa
from import data_blueprint # noqa
from import analytics_blueprint # noqa: E402
from import data_blueprint # noqa: E402
from fractalis.misc.controller import misc_blueprint # noqa: E402"Registering Flask blueprints.")
app.register_blueprint(analytics_blueprint, url_prefix='/analytics')
app.register_blueprint(data_blueprint, url_prefix='/data')
app.register_blueprint(misc_blueprint, url_prefix='/misc')
# registering all application celery tasks"Registering celery tasks.")
"""The /misc controller provides an API for everything that does not belong
in any of the other categories."""
import logging
import pkg_resources
from typing import Tuple
from flask import Blueprint, jsonify, Response
misc_blueprint = Blueprint('misc_blueprint', __name__)
logger = logging.getLogger(__name__)
@misc_blueprint.route('/version', methods=['GET'])
def get_version() -> Tuple[Response, int]:
version = pkg_resources.require('fractalis')[0].version
return jsonify({'version': version}), 201
"""This module provides tests for the misc controller."""
import re
import flask
import pytest
class TestMisc:
def test_client(self):
from fractalis import app
app.testing = True
with app.test_client() as test_client:
yield test_client
def test_get_version_returns_version(self, test_client):
rv = test_client.get('/misc/version')
body = flask.json.loads(rv.get_data())
assert re.match('^\d+.\d+.\d+$', body['version'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment