diff --git a/models/validator.py b/models/validator.py new file mode 100644 index 0000000..e3c39b6 --- /dev/null +++ b/models/validator.py @@ -0,0 +1,17 @@ +from .itm import AssertModel +from .executor import Response + + +class Validator: + def validate(self, asserts: list[AssertModel], response: Response) -> bool: + for assertion in asserts: + if not self._check(assertion, response): + return False + return True + + def _check(self, assertion: AssertModel, response: Response) -> bool: + if assertion.type == "status": + return response.status == assertion.value + if assertion.type == "json": + return True + return True