From: Alfredo Deza Date: Wed, 27 May 2015 12:58:46 +0000 (-0400) Subject: [BZ-1219310] ensure that truthy values are interpreted correctly X-Git-Tag: v1.5.26~21^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7256d4fece4861275dba224c84c2fd537158baf9;p=ceph-deploy.git [BZ-1219310] ensure that truthy values are interpreted correctly Signed-off-by: Alfredo Deza --- diff --git a/ceph_deploy/tests/unit/test_conf.py b/ceph_deploy/tests/unit/test_conf.py index 857f814..7bdc4fb 100644 --- a/ceph_deploy/tests/unit/test_conf.py +++ b/ceph_deploy/tests/unit/test_conf.py @@ -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