def test_disabled(self): ''' Test to ensure an Apache conf is disabled. ''' name = 'saltstack.com' ret = {'name': name, 'result': None, 'changes': {}, 'comment': ''} mock = MagicMock(side_effect=[True, True, False]) mock_str = MagicMock(return_value={'Status': ['disabled']}) with patch.dict(apache_conf.__salt__, {'apache.check_conf_enabled': mock, 'apache.a2disconf': mock_str}): comt = ('Apache conf {0} is set to be disabled.'.format(name)) ret.update({'comment': comt, 'changes': {'new': None, 'old': name}}) with patch.dict(apache_conf.__opts__, {'test': True}): self.assertDictEqual(apache_conf.disabled(name), ret) comt = ('Failed to disable {0} Apache conf'.format(name)) ret.update({'comment': comt, 'result': False, 'changes': {}}) with patch.dict(apache_conf.__opts__, {'test': False}): self.assertDictEqual(apache_conf.disabled(name), ret) comt = ('{0} already disabled.'.format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(apache_conf.disabled(name), ret)
def test_disabled(self): ''' Test to ensure an Apache conf is disabled. ''' name = 'saltstack.com' ret = {'name': name, 'result': None, 'changes': {}, 'comment': ''} mock = MagicMock(side_effect=[True, True, False]) mock_str = MagicMock(return_value={'Status': ['disabled']}) with patch.dict(apache_conf.__salt__, {'apache.check_conf_enabled': mock, 'apache.a2disconf': mock_str}): comt = ('Apache conf {0} is set to be disabled.'.format(name)) ret.update({'comment': comt, 'changes': {'new': None, 'old': name}}) with patch.dict(apache_conf.__opts__, {'test': True}): self.assertDictEqual(apache_conf.disabled(name), ret) comt = ('Failed to disable {0} Apache conf'.format(name)) ret.update({'comment': comt, 'result': False, 'changes': {}}) with patch.dict(apache_conf.__opts__, {'test': False}): self.assertDictEqual(apache_conf.disabled(name), ret) comt = ('{0} already disabled.'.format(name)) ret.update({'comment': comt, 'result': True}) self.assertDictEqual(apache_conf.disabled(name), ret)
def test_disabled(): """ Test to ensure an Apache conf is disabled. """ name = "saltstack.com" ret = {"name": name, "result": None, "changes": {}, "comment": ""} mock = MagicMock(side_effect=[True, True, False]) mock_str = MagicMock(return_value={"Status": ["disabled"]}) with patch.dict( apache_conf.__salt__, { "apache.check_conf_enabled": mock, "apache.a2disconf": mock_str }, ): comt = "Apache conf {} is set to be disabled.".format(name) ret.update({"comment": comt, "changes": {"new": None, "old": name}}) with patch.dict(apache_conf.__opts__, {"test": True}): assert apache_conf.disabled(name) == ret comt = "Failed to disable {} Apache conf".format(name) ret.update({"comment": comt, "result": False, "changes": {}}) with patch.dict(apache_conf.__opts__, {"test": False}): assert apache_conf.disabled(name) == ret comt = "{} already disabled.".format(name) ret.update({"comment": comt, "result": True}) assert apache_conf.disabled(name) == ret