From b9e0948256af817e63f901ec5277d3ef9fe36fdd Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Thu, 30 Mar 2017 15:33:19 +0800 Subject: unify raise exception process Change-Id: I109ef9550a57e218b6f5c9196812b33133d34134 Signed-off-by: SerenaFeng --- utils/test/testapi/opnfv_testapi/common/raises.py | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 utils/test/testapi/opnfv_testapi/common/raises.py (limited to 'utils/test/testapi/opnfv_testapi/common') diff --git a/utils/test/testapi/opnfv_testapi/common/raises.py b/utils/test/testapi/opnfv_testapi/common/raises.py new file mode 100644 index 000000000..ed3a84ee0 --- /dev/null +++ b/utils/test/testapi/opnfv_testapi/common/raises.py @@ -0,0 +1,31 @@ +import httplib + +from tornado import web + + +class Raiser(object): + code = httplib.OK + + def __init__(self, reason): + raise web.HTTPError(self.code, reason) + + +class BadRequest(Raiser): + code = httplib.BAD_REQUEST + + +class Forbidden(Raiser): + code = httplib.FORBIDDEN + + +class NotFound(Raiser): + code = httplib.NOT_FOUND + + +class Unauthorized(Raiser): + code = httplib.UNAUTHORIZED + + +class CodeTBD(object): + def __init__(self, code, reason): + raise web.HTTPError(code, reason) -- cgit 1.2.3-korg