def greater_than_constraint(self, fixture): other_field = IntegerField(label='other') greater_than_constraint = GreaterThanConstraint(other_field, '$label, $other_label') other_field.set_user_input('5', ignore_validation=True) #case: valid input with expected(NoException): greater_than_constraint.validate_parsed_value( 6 ) #case: invalid input with expected(GreaterThanConstraint): greater_than_constraint.validate_parsed_value( 5 )
def test_smaller_than_constraint(fixture): other_field = IntegerField(label='other') smaller_than_constraint = SmallerThanConstraint(other_field, '$label, $other_label') other_field.set_user_input('5', ignore_validation=True) #case: valid input with expected(NoException): smaller_than_constraint.validate_parsed_value( 4 ) #case: invalid input with expected(SmallerThanConstraint): smaller_than_constraint.validate_parsed_value( 5 )
def integer_validation(self, fixture): field = IntegerField() # Case invalid with expected(IntegerConstraint): field.set_user_input('sdfdf') # Case valid with expected(NoException): field.set_user_input('3') # Case Max field = IntegerField(max_value=4) with expected(MaxValueConstraint): field.set_user_input('5') # Case Min field = IntegerField(min_value=4) with expected(MinValueConstraint): field.set_user_input('3')