(self, validator_dict)
validate with functions

        Args:
            validator_dict (dict): validator dict
                {
                    "check": "status_code",
                    "check_value": 200,
                    "expect": 201,
                    "comparator": "eq"
                }
validate with functions
validate with functions
def _do_validation(self, validator_dict):
        """ validate with functions

        Args:
            validator_dict (dict): validator dict
                {
                    "check": "status_code",
                    "check_value": 200,
                    "expect": 201,
                    "comparator": "eq"
                }

        """
        # TODO: move comparator uniform to init_test_suites
        comparator = utils.get_uniform_comparator(validator_dict["comparator"])
        validate_func = parser.get_mapping_function(comparator, self.FUNCTIONS_MAPPING)

        check_item = validator_dict["check"]
        check_value = validator_dict["check_value"]
        expect_value = validator_dict["expect"]

        if (check_value is None or expect_value is None) \
                and comparator not in ["is", "eq", "equals", "=="]:
            raise exceptions.ParamsError("Null value can only be compared with comparator: eq/equals/==")

        validate_msg = "validate: {} {} {}({})".format(
            check_item,
            comparator,
            expect_value,
            type(expect_value).__name__
        )

        try:
            validator_dict["check_result"] = "pass"
            validate_func(check_value, expect_value)
            validate_msg += "\t==> pass"
            logger.log_debug(validate_msg)
        except (AssertionError, TypeError):
            validate_msg += "\t==> fail"
            validate_msg += "\n{}({}) {} {}({})".format(
                check_value,
                type(check_value).__name__,
                comparator,
                expect_value,
                type(expect_value).__name__
            )
            logger.log_error(validate_msg)
            validator_dict["check_result"] = "fail"
            raise exceptions.ValidationFailure(validate_msg)
def _do_validation ( self , validator_dict ) : # TODO: move comparator uniform to init_test_suites comparator = utils . get_uniform_comparator ( validator_dict [ "comparator" ] ) validate_func = parser . get_mapping_function ( comparator , self . FUNCTIONS_MAPPING ) check_item = validator_dict [ "check" ] check_value = validator_dict [ "check_value" ] expect_value = validator_dict [ "expect" ] if ( check_value is None or expect_value is None ) and comparator not in [ "is" , "eq" , "equals" , "==" ] : raise exceptions . ParamsError ( "Null value can only be compared with comparator: eq/equals/==" ) validate_msg = "validate: {} {} {}({})" . format ( check_item , comparator , expect_value , type ( expect_value ) . __name__ ) try : validator_dict [ "check_result" ] = "pass" validate_func ( check_value , expect_value ) validate_msg += "\t==> pass" logger . log_debug ( validate_msg ) except ( AssertionError , TypeError ) : validate_msg += "\t==> fail" validate_msg += "\n{}({}) {} {}({})" . format ( check_value , type ( check_value ) . __name__ , comparator , expect_value , type ( expect_value ) . __name__ ) logger . log_error ( validate_msg ) validator_dict [ "check_result" ] = "fail" raise exceptions . ValidationFailure ( validate_msg )