Пример #1
0
    def test_enable(self):
        '''
        Test to enable the puppet agent
        '''
        mock_lst = MagicMock(return_value=[])
        with patch.dict(puppet.__salt__, {'cmd.run': mock_lst}):
            mock = MagicMock(return_value=True)
            with patch.object(os.path, 'isfile', mock):
                mock = MagicMock(return_value=True)
                with patch.object(os, 'remove', mock):
                    self.assertTrue(puppet.enable())
                with patch.object(os, 'remove', MagicMock(side_effect=IOError)):
                    self.assertRaises(CommandExecutionError, puppet.enable)

            self.assertFalse(puppet.enable())
Пример #2
0
def test_enable():
    """
    Test to enable the puppet agent
    """
    mock_lst = MagicMock(return_value=[])
    with patch.dict(puppet.__salt__, {"cmd.run": mock_lst}):
        mock = MagicMock(return_value=True)
        with patch.object(os.path, "isfile", mock):
            mock = MagicMock(return_value=True)
            with patch.object(os, "remove", mock):
                assert puppet.enable()
            with patch.object(os, "remove", MagicMock(side_effect=IOError)):
                pytest.raises(CommandExecutionError, puppet.enable)

        assert not puppet.enable()
Пример #3
0
    def test_enable(self):
        '''
            Test to enable the puppet agent
        '''
        mock_lst = MagicMock(return_value=[])
        with patch.dict(puppet.__salt__, {'cmd.run': mock_lst}):
            mock = MagicMock(return_value=True)
            with patch.object(os.path, 'isfile', mock):
                mock = MagicMock(return_value=True)
                with patch.object(os, 'remove', mock):
                    self.assertTrue(puppet.enable())

                with patch.object(os, 'remove',
                                    MagicMock(side_effect=IOError)):
                    self.assertRaises(CommandExecutionError, puppet.enable)

            self.assertFalse(puppet.enable())