From 75991e1f875f2357156942c5479a5d3ce7a92a5c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 23 Jul 2015 14:41:14 +0200 Subject: [PATCH] configtypes: Add tests for BoolAsk. --- tests/config/test_configtypes.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/config/test_configtypes.py b/tests/config/test_configtypes.py index c76f50de2..dc9fd3163 100644 --- a/tests/config/test_configtypes.py +++ b/tests/config/test_configtypes.py @@ -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."""