def test_a2enconf_exception(self): ''' Test if it runs a2enconf for the given conf. ''' mock = MagicMock(side_effect=Exception('error')) with patch.dict(deb_apache.__salt__, {'cmd.retcode': mock}): self.assertEqual(str(deb_apache.a2enconf('security')), 'error')
def test_a2enconf_exception(self): ''' Test if it runs a2enconf for the given conf. ''' with patch('salt.utils.path.which', MagicMock(return_value='a2enconf')): mock = MagicMock(side_effect=Exception('error')) with patch.dict(deb_apache.__salt__, {'cmd.retcode': mock}): self.assertEqual(six.text_type(deb_apache.a2enconf('security')), 'error')
def test_a2enconf_exception(self): """ Test if it runs a2enconf for the given conf. """ with patch("salt.utils.path.which", MagicMock(return_value="a2enconf")): mock = MagicMock(side_effect=Exception("error")) with patch.dict(deb_apache.__salt__, {"cmd.retcode": mock}): self.assertEqual(str(deb_apache.a2enconf("security")), "error")
def test_a2enconf(self): ''' Test if it runs a2enconf for the given conf. ''' mock = MagicMock(return_value=2) with patch.dict(deb_apache.__salt__, {'cmd.retcode': mock}): self.assertEqual(deb_apache.a2enconf('security'), {'Name': 'Apache2 Enable Conf', 'Conf': 'security', 'Status': 2})
def test_a2enconf_enabled(self): ''' Test if it runs a2enconf for the given conf. ''' with patch('salt.utils.path.which', MagicMock(return_value='a2enconf')): mock = MagicMock(return_value=0) with patch.dict(deb_apache.__salt__, {'cmd.retcode': mock}): self.assertEqual(deb_apache.a2enconf('security'), {'Name': 'Apache2 Enable Conf', 'Conf': 'security', 'Status': 'Conf security enabled'})
def test_a2enconf(self): """ Test if it runs a2enconf for the given conf. """ with patch("salt.utils.path.which", MagicMock(return_value="a2enconf")): mock = MagicMock(return_value=2) with patch.dict(deb_apache.__salt__, {"cmd.retcode": mock}): self.assertEqual( deb_apache.a2enconf("security"), { "Name": "Apache2 Enable Conf", "Conf": "security", "Status": 2 }, )