summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/common/check.py
diff options
context:
space:
mode:
Diffstat (limited to 'testapi/opnfv_testapi/common/check.py')
-rw-r--r--testapi/opnfv_testapi/common/check.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/common/check.py b/testapi/opnfv_testapi/common/check.py
index e80b1c6..1dff37a 100644
--- a/testapi/opnfv_testapi/common/check.py
+++ b/testapi/opnfv_testapi/common/check.py
@@ -102,6 +102,19 @@ def carriers_exist(xstep):
return wrap
+def values_check(xstep):
+ @functools.wraps(xstep)
+ def wrap(self, *args, **kwargs):
+ checks = kwargs.pop('values_check', {})
+ if checks:
+ for field, check, options in checks:
+ if not check(field, options):
+ raises.BadRequest(message.invalid_value(field, options))
+ ret = yield gen.coroutine(xstep)(self, *args, **kwargs)
+ raise gen.Return(ret)
+ return wrap
+
+
def new_not_exists(xstep):
@functools.wraps(xstep)
def wrap(self, *args, **kwargs):