validate response: check validators and variables_mapping

This commit is contained in:
debugtalk
2017-06-29 16:36:59 +08:00
parent 2a904ec36a
commit 7e3f1bdcc8
2 changed files with 31 additions and 2 deletions

View File

@@ -89,13 +89,14 @@ class ResponseObject(object):
try:
value = variables_mapping[validator_key]
validator_dict["value"] = value
expected_value = validator_dict["expected"]
except KeyError:
raise exception.ParamsError("invalid validator %s" % validator_key)
match_expected = utils.match_expected(
value,
validator_dict["expected"],
validator_dict["comparator"]
expected_value,
validator_dict.get("comparator", "eq")
)
if not match_expected: