Exemplo n.º 1
0
 def setUp(self):
     os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(
         self.BASE_DIR, "config-tests.yml")
     ms = Microservice(service="my-ms", path=__file__)
     self.app = ms.create_app()
     with self.app.app_context():
         self.request = ms.requests
Exemplo n.º 2
0
 def setUp(self):
     os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(
         self.BASE_DIR, "config-tests-requests.yml")
     ms = Microservice(path=__file__)
     ms.reload_conf()
     self.app = ms.create_app()
     self.request = ms.requests
Exemplo n.º 3
0
 def __init__(self):
     """
     Initialize the flask endpoint and launch the function that will throw
     the threads that will update the metrics.
     """
     self.lock = {}
     self.app = Microservice().create_app()
     self.logger = self.app.logger
     self.read_config()
     self.serve_endpoints()
def create_app():
    """Initialize the Flask app, register blueprints and intialize all libraries like Swagger, database, the trace system...
    return the app and the database objects.
    :return:
    """
    {% if cookiecutter.create_model_class == 'y' -%}
    ms = MyMicroservice(service="ms", path=__file__)
    {% else %}
    ms = Microservice(service="ms", path=__file__)
    {% endif %}
    return ms.create_app()
Exemplo n.º 5
0
from flask import jsonify

from pyms.flask.app import Microservice

ms = Microservice(path=__file__)
app = ms.create_app()


@app.route("/")
def example():
    return jsonify({"main": "hello world"})


if __name__ == '__main__':
    app.run()
Exemplo n.º 6
0
from flask import current_app, jsonify, request

from pyms.flask.app import Microservice

ms = Microservice()
app = ms.create_app()


@app.route("/")
def index():
    app.logger.info("There are my headers: \n{}".format(request.headers))
    return jsonify(
        {"main": "hello world {}".format(current_app.config["APP_NAME"])})


if __name__ == "__main__":
    app.run()
Exemplo n.º 7
0
from pyms.flask.app import Microservice

ms = Microservice(service="my-ms", path=__file__)
app = ms.create_app()

if __name__ == '__main__':
    app.run()
Exemplo n.º 8
0
 def setUp(self):
     os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(
         self.BASE_DIR, "config-tests-metrics.yml")
     ms = Microservice(service="my-ms", path=__file__)
     self.app = ms.create_app()
     self.client = self.app.test_client()
Exemplo n.º 9
0
from flask import jsonify

from pyms.flask.app import Microservice

ms = Microservice(service="my-minimal-microservice", path=__file__)
app = ms.create_app()


@app.route("/")
def example():
    return jsonify({"main": "hello world"})


if __name__ == '__main__':
    app.run()
Exemplo n.º 10
0
 def test_singleton_inherit_conf(self):
     ms1 = Microservice(path=__file__)
     ms2 = MyMicroservice()
     self.assertEqual(ms1.config.subservice1, ms2.config.subservice1)
Exemplo n.º 11
0
 def test_singleton_child_class(self):
     ms1 = Microservice(path=__file__)
     ms2 = MyMicroservice()
     self.assertNotEqual(ms1, ms2)
Exemplo n.º 12
0
 def test_singleton(self):
     ms1 = Microservice(path=__file__)
     ms2 = Microservice(path=__file__)
     self.assertEqual(ms1, ms2)
Exemplo n.º 13
0
 def setUp(self):
     os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(self.BASE_DIR, "config-tests-service-discovery.yml")
     ms = Microservice(path=__file__)
     ms.reload_conf()
     self.ms = ms
Exemplo n.º 14
0
 def setUp(self):
     os.environ[CONFIGMAP_FILE_ENVIRONMENT] = os.path.join(
         os.path.dirname(os.path.abspath(__file__)), "config-tests.yml")
     ms = Microservice(service="my-ms", path=__file__)
     self.app = ms.create_app()
     self.client = self.app.test_client()