mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
change: rename to StepRequestValidation
This commit is contained in:
+24
-24
@@ -50,35 +50,35 @@ class Config(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class StepValidation(object):
|
class StepRequestValidation(object):
|
||||||
def __init__(self, step: TStep):
|
def __init__(self, step: TStep):
|
||||||
self.__t_step = step
|
self.__t_step = step
|
||||||
|
|
||||||
def assert_equal(self, jmes_path: Text, expected_value: Any) -> "StepValidation":
|
def assert_equal(self, jmes_path: Text, expected_value: Any) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"equal": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"equal": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_not_equal(
|
def assert_not_equal(
|
||||||
self, jmes_path: Text, expected_value: Any
|
self, jmes_path: Text, expected_value: Any
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"not_equal": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"not_equal": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_greater_than(
|
def assert_greater_than(
|
||||||
self, jmes_path: Text, expected_value: Union[int, float]
|
self, jmes_path: Text, expected_value: Union[int, float]
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"greater_than": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"greater_than": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_less_than(
|
def assert_less_than(
|
||||||
self, jmes_path: Text, expected_value: Union[int, float]
|
self, jmes_path: Text, expected_value: Union[int, float]
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"less_than": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"less_than": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_greater_or_equals(
|
def assert_greater_or_equals(
|
||||||
self, jmes_path: Text, expected_value: Union[int, float]
|
self, jmes_path: Text, expected_value: Union[int, float]
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append(
|
self.__t_step.validators.append(
|
||||||
{"greater_or_equals": [jmes_path, expected_value]}
|
{"greater_or_equals": [jmes_path, expected_value]}
|
||||||
)
|
)
|
||||||
@@ -86,19 +86,19 @@ class StepValidation(object):
|
|||||||
|
|
||||||
def assert_less_or_equals(
|
def assert_less_or_equals(
|
||||||
self, jmes_path: Text, expected_value: Union[int, float]
|
self, jmes_path: Text, expected_value: Union[int, float]
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"less_or_equals": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"less_or_equals": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_length_equal(
|
def assert_length_equal(
|
||||||
self, jmes_path: Text, expected_value: int
|
self, jmes_path: Text, expected_value: int
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"length_equal": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"length_equal": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_length_greater_than(
|
def assert_length_greater_than(
|
||||||
self, jmes_path: Text, expected_value: int
|
self, jmes_path: Text, expected_value: int
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append(
|
self.__t_step.validators.append(
|
||||||
{"length_greater_than": [jmes_path, expected_value]}
|
{"length_greater_than": [jmes_path, expected_value]}
|
||||||
)
|
)
|
||||||
@@ -106,7 +106,7 @@ class StepValidation(object):
|
|||||||
|
|
||||||
def assert_length_less_than(
|
def assert_length_less_than(
|
||||||
self, jmes_path: Text, expected_value: int
|
self, jmes_path: Text, expected_value: int
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append(
|
self.__t_step.validators.append(
|
||||||
{"length_less_than": [jmes_path, expected_value]}
|
{"length_less_than": [jmes_path, expected_value]}
|
||||||
)
|
)
|
||||||
@@ -114,7 +114,7 @@ class StepValidation(object):
|
|||||||
|
|
||||||
def assert_length_greater_or_equals(
|
def assert_length_greater_or_equals(
|
||||||
self, jmes_path: Text, expected_value: int
|
self, jmes_path: Text, expected_value: int
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append(
|
self.__t_step.validators.append(
|
||||||
{"length_greater_or_equals": [jmes_path, expected_value]}
|
{"length_greater_or_equals": [jmes_path, expected_value]}
|
||||||
)
|
)
|
||||||
@@ -122,7 +122,7 @@ class StepValidation(object):
|
|||||||
|
|
||||||
def assert_length_less_or_equals(
|
def assert_length_less_or_equals(
|
||||||
self, jmes_path: Text, expected_value: int
|
self, jmes_path: Text, expected_value: int
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append(
|
self.__t_step.validators.append(
|
||||||
{"length_less_or_equals": [jmes_path, expected_value]}
|
{"length_less_or_equals": [jmes_path, expected_value]}
|
||||||
)
|
)
|
||||||
@@ -130,41 +130,41 @@ class StepValidation(object):
|
|||||||
|
|
||||||
def assert_string_equals(
|
def assert_string_equals(
|
||||||
self, jmes_path: Text, expected_value: int
|
self, jmes_path: Text, expected_value: int
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"string_equals": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"string_equals": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_startswith(
|
def assert_startswith(
|
||||||
self, jmes_path: Text, expected_value: Text
|
self, jmes_path: Text, expected_value: Text
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"startswith": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"startswith": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_endswith(
|
def assert_endswith(
|
||||||
self, jmes_path: Text, expected_value: Text
|
self, jmes_path: Text, expected_value: Text
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"endswith": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"endswith": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_regex_match(
|
def assert_regex_match(
|
||||||
self, jmes_path: Text, expected_value: Text
|
self, jmes_path: Text, expected_value: Text
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"regex_match": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"regex_match": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_contains(self, jmes_path: Text, expected_value: Any) -> "StepValidation":
|
def assert_contains(self, jmes_path: Text, expected_value: Any) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"contains": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"contains": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_contained_by(
|
def assert_contained_by(
|
||||||
self, jmes_path: Text, expected_value: Any
|
self, jmes_path: Text, expected_value: Any
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"contained_by": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"contained_by": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def assert_type_match(
|
def assert_type_match(
|
||||||
self, jmes_path: Text, expected_value: Text
|
self, jmes_path: Text, expected_value: Text
|
||||||
) -> "StepValidation":
|
) -> "StepRequestValidation":
|
||||||
self.__t_step.validators.append({"type_match": [jmes_path, expected_value]})
|
self.__t_step.validators.append({"type_match": [jmes_path, expected_value]})
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@@ -188,8 +188,8 @@ class StepRequestExtraction(object):
|
|||||||
# # TODO: extract response json with jsonpath
|
# # TODO: extract response json with jsonpath
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
def validate(self) -> StepValidation:
|
def validate(self) -> StepRequestValidation:
|
||||||
return StepValidation(self.__t_step)
|
return StepRequestValidation(self.__t_step)
|
||||||
|
|
||||||
def perform(self) -> TStep:
|
def perform(self) -> TStep:
|
||||||
return self.__t_step
|
return self.__t_step
|
||||||
@@ -241,8 +241,8 @@ class RequestWithOptionalArgs(object):
|
|||||||
def extract(self) -> StepRequestExtraction:
|
def extract(self) -> StepRequestExtraction:
|
||||||
return StepRequestExtraction(self.__t_step)
|
return StepRequestExtraction(self.__t_step)
|
||||||
|
|
||||||
def validate(self) -> StepValidation:
|
def validate(self) -> StepRequestValidation:
|
||||||
return StepValidation(self.__t_step)
|
return StepRequestValidation(self.__t_step)
|
||||||
|
|
||||||
def perform(self) -> TStep:
|
def perform(self) -> TStep:
|
||||||
return self.__t_step
|
return self.__t_step
|
||||||
@@ -305,7 +305,7 @@ class Step(object):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
step: Union[
|
step: Union[
|
||||||
StepValidation, StepRequestExtraction, RequestWithOptionalArgs, RunTestCase
|
StepRequestValidation, StepRequestExtraction, RequestWithOptionalArgs, RunTestCase
|
||||||
],
|
],
|
||||||
):
|
):
|
||||||
self.__t_step = step.perform()
|
self.__t_step = step.perform()
|
||||||
|
|||||||
Reference in New Issue
Block a user