From 0620b2cbb21714c1a5e485186c46c2c24485ef37 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Wed, 5 Apr 2017 16:23:03 +0800 Subject: unify error message in TestAPI Change-Id: I994feb7bf340c9e48bebe9fdf3dc3a76bc254652 Signed-off-by: SerenaFeng --- testapi/opnfv_testapi/common/message.py | 46 +++++++++++++++++++++++++++++++++ testapi/opnfv_testapi/common/raises.py | 8 ++++++ 2 files changed, 54 insertions(+) create mode 100644 testapi/opnfv_testapi/common/message.py (limited to 'testapi/opnfv_testapi/common') diff --git a/testapi/opnfv_testapi/common/message.py b/testapi/opnfv_testapi/common/message.py new file mode 100644 index 0000000..98536ff --- /dev/null +++ b/testapi/opnfv_testapi/common/message.py @@ -0,0 +1,46 @@ +############################################################################## +# Copyright (c) 2017 ZTE Corp +# feng.xiaowei@zte.com.cn +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +not_found_base = 'Could Not Found' +exist_base = 'Already Exists' + + +def no_body(): + return 'No Body' + + +def not_found(key, value): + return '{} {} [{}]'.format(not_found_base, key, value) + + +def missing(name): + return '{} Missing'.format(name) + + +def exist(key, value): + return '{} [{}] {}'.format(key, value, exist_base) + + +def bad_format(error): + return 'Bad Format [{}]'.format(error) + + +def unauthorized(): + return 'No Authentication Header' + + +def invalid_token(): + return 'Invalid Token' + + +def no_update(): + return 'Nothing to update' + + +def must_int(name): + return '{} must be int'.format(name) diff --git a/testapi/opnfv_testapi/common/raises.py b/testapi/opnfv_testapi/common/raises.py index ed3a84e..ec6b8a5 100644 --- a/testapi/opnfv_testapi/common/raises.py +++ b/testapi/opnfv_testapi/common/raises.py @@ -1,3 +1,11 @@ +############################################################################## +# Copyright (c) 2017 ZTE Corp +# feng.xiaowei@zte.com.cn +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## import httplib from tornado import web -- cgit 1.2.3-korg