Esempio n. 1
0
 def test_register_one_plugin(self):
     plugin_registry = {
         "check-expired-session-plugin": {
             "id": "check-expired-session-plugin",
             "info": {
                 "modules": ["ui"]
             }
         }
     }
     with mock.patch.multiple(plugins, PLUGIN_REGISTRY={}):
         register_plugin("check-expired-session-plugin")
         self.assertDictEqual(plugin_registry, plugins.PLUGIN_REGISTRY)
Esempio n. 2
0
 def test_return_only_registered_plugins_not_empty(self):
     plugin_data = {
         u"plugins": [{
             u"id": u"some-example-plugin",
             u"info": {
                 u"modules": [u"ui"]
             }
         }]
     }
     with mock.patch.multiple(plugins, PLUGIN_REGISTRY={}):
         register_plugin("some-example-plugin")
         response = application.test_client().get("/v2/plugins")
         self.assertDictEqual({}, json.loads(response.data))
Esempio n. 3
0
        (hasattr(request, "user") and request.user.current_account.id) or None,
        "location":
        response.headers.get("Location"),
        "user-agent":
        request.headers.get("User-Agent"),
        "qstring":
        request.args,
        "current_exception":
        _get_current_exception_if_exists(request),
    })
    return response


@application.errorhandler(Exception)
def handler_500(error):
    current_exception = {
        "message": str(error),
        "traceback": traceback.format_exc(),
        "type": sys.exc_info()[0].__name__,
    }
    request.current_exception = current_exception

    return Response(response=json.dumps(current_exception), status=500)


marathon.log = dev_null_logger

register_plugin("example-plugin")
register_plugin("session-checker-plugin")
load_all_metrics_plugins(application)