configtypes: Add tests for BoolAsk.

This commit is contained in:
Florian Bruhin 2015-07-23 14:41:14 +02:00
parent 8b9c8eb0bf
commit 75991e1f87

View File

@ -303,6 +303,36 @@ class TestBool:
klass().validate(val)
class TestBoolAsk:
"""Test BoolAsk."""
TESTS = {
'ask': 'ask',
'ASK': 'ask',
}
TESTS.update(TestBool.TESTS)
INVALID = TestBool.INVALID
@pytest.fixture
def klass(self):
return configtypes.BoolAsk
@pytest.mark.parametrize('val, expected', TESTS.items())
def test_transform(self, klass, val, expected):
assert klass().transform(val) == expected
@pytest.mark.parametrize('val', TESTS)
def test_validate_valid(self, klass, val):
klass(none_ok=True).validate(val)
@pytest.mark.parametrize('val', INVALID)
def test_validate_invalid(self, klass, val):
with pytest.raises(configexc.ValidationError):
klass().validate(val)
class TestInt:
"""Test Int."""