-
Notifications
You must be signed in to change notification settings - Fork 4
Description
`
___________________________________ test_validate_min_max ___________________________________
def test_validate_min_max():
# Checks if values within and not within the min and max can be validated,
# also checks what happens when strings and floats are validated
int_value = IntValue("test", "label", "help")
int_value.setMin(1)
int_value.setMax(10)
assert int_value.validate(5)
assert not int_value.validate(0)
assert not int_value.validate(11)
assert int_value.validate("string")
tests/test_Models/test_Values/test_IntValue.py:61:
self = <Granny.Models.Values.IntValue.IntValue object at 0x79345f1b1e70>, value = 'string'
def validate(self, value: Any) -> bool:
"""
{@inheritdoc}
"""
if self.valid_values != [] and value not in self.valid_values:
return False
if self.min_value > value or self.max_value < value:
E TypeError: '>' not supported between instances of 'int' and 'str'
Granny/Models/Values/IntValue.py:59: TypeError
____________________________________ test_validate_type _____________________________________
def test_validate_type():
# Checks if ints, strings, and floats can be validated
int_value = IntValue("test", "label", "help")
assert int_value.validate("string")
tests/test_Models/test_Values/test_IntValue.py:70:
self = <Granny.Models.Values.IntValue.IntValue object at 0x79345f1b13f0>, value = 'string'
def validate(self, value: Any) -> bool:
"""
{@inheritdoc}
"""
if self.valid_values != [] and value not in self.valid_values:
return False
if self.min_value > value or self.max_value < value:
E TypeError: '>' not supported between instances of 'float' and 'str'
Granny/Models/Values/IntValue.py:59: TypeError
`
An issue with being able to validate wrong value types, e.g. a string for the int value class. In the validate function it should check whether the value is the correct value before comparing the value with valid values.