def test_integer_field_range_success(): f = Integer() assert f._validate_range((1, 10), 1) == 1 assert f._validate_range((1, 10), 5) == 5 assert f._validate_range((1, 10), 10) == 10
def test_integer_field_range_fail(): f = Integer() for fail_val in (100, 0, -5): with pytest.raises(FieldSet.Error): f._validate_range((1, 10), fail_val)
def test_integer_field_validate_numberic_str(): f = Integer() assert f._validate_field('10') == 10
def test_integer_field_validate_non_acceptable_value(): f = Integer() for fail_val in ('should not work', None, '10.10'): with pytest.raises(FieldSet.Error) as e: f._validate_field(fail_val) assert 'Field "{}" is not a number'.format(f._name) in str(e)
def test_integer_field_validate(): f = Integer() assert f._validate_field(1000) == 1000
def test_integer_field_validate_decimal(): f = Integer() assert f._validate_field(10.10) == 10
def test_integer_field_range_success(): f = Integer() assert f._validate_range(1, (1, 10)) == 1 assert f._validate_range(5, (1, 10)) == 5 assert f._validate_range(10, (1, 10)) == 10