]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[BZ-1219310] ensure that truthy values are interpreted correctly
authorAlfredo Deza <adeza@redhat.com>
Wed, 27 May 2015 12:58:46 +0000 (08:58 -0400)
committerAlfredo Deza <adeza@redhat.com>
Wed, 27 May 2015 15:30:43 +0000 (11:30 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
ceph_deploy/tests/unit/test_conf.py

index 857f814855e3fbdea3b95d08bcee295c5867440e..7bdc4fb3b29942faf30c23c6d33324e7addf16bb 100644 (file)
@@ -1,5 +1,6 @@
 from cStringIO import StringIO
 from textwrap import dedent
+import pytest
 from mock import Mock, patch
 from ceph_deploy import conf
 from ceph_deploy.tests import fakes
@@ -147,6 +148,10 @@ class TestConfGetList(object):
         assert cfg.get_default_repo() is False
 
 
+truthy_values = ['yes', 'true', 'on']
+falsy_values = ['no', 'false', 'off']
+
+
 class TestSetOverrides(object):
 
     def setup(self):
@@ -167,3 +172,21 @@ class TestSetOverrides(object):
         self.conf.items = Mock(return_value=(('bar', 1),))
         arg_obj = conf.cephdeploy.set_overrides(self.args, self.conf)
         assert arg_obj.bar == 1
+
+    @pytest.mark.parametrize('value', truthy_values)
+    def test_override_truthy_values(self, value):
+        self.conf.sections = Mock(
+            return_value=['ceph-deploy-global', 'ceph-deploy-install']
+        )
+        self.conf.items = Mock(return_value=(('bar', value),))
+        arg_obj = conf.cephdeploy.set_overrides(self.args, self.conf)
+        assert arg_obj.bar is True
+
+    @pytest.mark.parametrize('value', falsy_values)
+    def test_override_falsy_values(self, value):
+        self.conf.sections = Mock(
+            return_value=['ceph-deploy-global', 'ceph-deploy-install']
+        )
+        self.conf.items = Mock(return_value=(('bar', value),))
+        arg_obj = conf.cephdeploy.set_overrides(self.args, self.conf)
+        assert arg_obj.bar is False