def test_combined_validator(self): """Test allowed values - ranges and values combination""" allowed_value1 = AllowedValue() allowed_value1.allowed_type = ALLOWEDVALUETYPE.RANGE allowed_value1.minval = 1 allowed_value1.maxval = 11 allowed_value1.spacing = 2 allowed_value1.range_closure = RANGECLOSURETYPE.OPEN allowed_value2 = AllowedValue() allowed_value2.allowed_type = ALLOWEDVALUETYPE.VALUE allowed_value2.value = 15 inpt = get_input(allowed_values=[allowed_value1, allowed_value2]) inpt.data = 1 self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'Range OPEN closure') inpt.data = 15 self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'AllowedValue') inpt.data = 13 self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'Out of range')
def test_allowedvalues_values_validator(self): """Test allowed values - values""" allowed_value = AllowedValue() allowed_value.allowed_type = ALLOWEDVALUETYPE.VALUE allowed_value.value = 1 inpt = get_input(allowed_values = [allowed_value]) self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'Allowed value 1 allowed') inpt.data = 2 self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'Allowed value 2 NOT allowed')
def test_combined_validator(self): """Test allowed values - ranges and values combination""" allowed_value1 = AllowedValue() allowed_value1.allowed_type = ALLOWEDVALUETYPE.RANGE allowed_value1.minval = 1 allowed_value1.maxval = 11 allowed_value1.spacing = 2 allowed_value1.range_closure = RANGECLOSURETYPE.OPEN allowed_value2 = AllowedValue() allowed_value2.allowed_type = ALLOWEDVALUETYPE.VALUE allowed_value2.value = 15 inpt = get_input(allowed_values = [allowed_value1, allowed_value2]) inpt.data = 1 self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'Range OPEN closure') inpt.data = 15 self.assertTrue(validate_allowed_values(inpt, MODE.SIMPLE), 'AllowedValue') inpt.data = 13 self.assertFalse(validate_allowed_values(inpt, MODE.SIMPLE), 'Out of range')