Esempio n. 1
0
def _safe_handle(handler, args):
    try:
        start_time = time.time()
        rez = handler.handle(args)
        json_response = json_utils.to_json("response", rez)

        request_time = time.time() - start_time

        response = make_response(json_response)
        response.headers['Request-time'] = str(request_time)

        return response
    except BaseException as e:
        if not isinstance(e, BaseFMSException):
            LOG.exception(e)
        return json_utils.to_json("error", InnerServerError(e.message))
Esempio n. 2
0
    def test_json_serializable(self):
        class JsonClass(json_utils.JsonSerializable):
            pass

        obj = JsonClass()
        json_utils.to_json("k", obj)
Esempio n. 3
0
    def test_json_serializable(self):
        class JsonClass(json_utils.JsonSerializable):
            pass

        obj = JsonClass()
        json_utils.to_json("k", obj)
Esempio n. 4
0
 def test_exception(self):
     exception = ValueError("test")
     expected = '{"resp": "test"}'
     self.assertEqual(json_utils.to_json("resp", exception), expected)
Esempio n. 5
0
 def test_exception(self):
     exception = ValueError("test")
     expected = '{"resp": "test"}'
     self.assertEqual(json_utils.to_json("resp", exception), expected)