def test_disable(self): ''' Test to disable the puppet agent ''' mock_lst = MagicMock(return_value=[]) with patch.dict(puppet.__salt__, {'cmd.run': mock_lst}): mock = MagicMock(side_effect=[True, False]) with patch.object(os.path, 'isfile', mock): self.assertFalse(puppet.disable()) with patch('salt.utils.fopen', mock_open()): self.assertTrue(puppet.disable()) with patch('salt.utils.fopen', mock_open()) as m_open: helper_open = m_open() helper_open.write.assertRaises(CommandExecutionError, puppet.disable)
def test_disable(): """ Test to disable the puppet agent """ mock_lst = MagicMock(return_value=[]) with patch.dict(puppet.__salt__, {"cmd.run": mock_lst}): mock = MagicMock(side_effect=[True, False]) with patch.object(os.path, "isfile", mock): assert not puppet.disable() with patch("salt.utils.files.fopen", mock_open()): assert puppet.disable() try: with patch("salt.utils.files.fopen", mock_open()) as m_open: m_open.side_effect = IOError(13, "Permission denied:", "/file") pytest.raises(CommandExecutionError, puppet.disable) except StopIteration: pass
def test_disable(self): ''' Test to disable the puppet agent ''' mock_lst = MagicMock(return_value=[]) with patch.dict(puppet.__salt__, {'cmd.run': mock_lst}): mock = MagicMock(side_effect=[True, False]) with patch.object(os.path, 'isfile', mock): self.assertFalse(puppet.disable()) with patch('salt.utils.files.fopen', mock_open()): self.assertTrue(puppet.disable()) try: with patch('salt.utils.files.fopen', mock_open()) as m_open: m_open.side_effect = IOError(13, 'Permission denied:', '/file') self.assertRaises(CommandExecutionError, puppet.disable) except StopIteration: pass
def test_disable(self): ''' Test to disable the puppet agent ''' mock_lst = MagicMock(return_value=[]) with patch.dict(puppet.__salt__, {'cmd.run': mock_lst}): mock = MagicMock(side_effect=[True, False]) with patch.object(os.path, 'isfile', mock): self.assertFalse(puppet.disable()) with patch('salt.utils.fopen', mock_open()): self.assertTrue(puppet.disable()) try: with patch('salt.utils.fopen', mock_open()) as m_open: m_open.side_effect = IOError(13, 'Permission denied:', '/file') self.assertRaises(CommandExecutionError, puppet.disable) except StopIteration: pass