def test_a2dissite_exception(self): """ Test if it runs a2dissite for the given site. """ mock = MagicMock(side_effect=Exception("error")) with patch.dict(deb_apache.__salt__, {"cmd.retcode": mock}): self.assertEqual( six.text_type(deb_apache.a2dissite("saltstack.com")), "error")
def test_a2dissite_exception(self): ''' Test if it runs a2dissite for the given site. ''' mock = MagicMock(side_effect=Exception('error')) with patch.dict(deb_apache.__salt__, {'cmd.retcode': mock}): self.assertEqual(str(deb_apache.a2dissite('saltstack.com')), 'error')
def test_a2dissite_notfound(self): ''' Test if it runs a2dissite for the given site. ''' mock = MagicMock(return_value=256) with patch.dict(deb_apache.__salt__, {'cmd.retcode': mock}): self.assertEqual(deb_apache.a2dissite('saltstack.com'), {'Name': 'Apache2 Disable Site', 'Site': 'saltstack.com', 'Status': 'Site saltstack.com Not found'})
def test_a2dissite(self): """ Test if it runs a2dissite for the given site. """ mock = MagicMock(return_value=2) with patch.dict(deb_apache.__salt__, {"cmd.retcode": mock}): self.assertEqual( deb_apache.a2dissite("saltstack.com"), { "Name": "Apache2 Disable Site", "Site": "saltstack.com", "Status": 2 }, )