コード例 #1
0
ファイル: puppet_test.py プロジェクト: zhugehui9527/salt
    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)
コード例 #2
0
ファイル: puppet_test.py プロジェクト: HowardMei/saltstack
    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)
コード例 #3
0
ファイル: test_puppet.py プロジェクト: nicholasmhughes/salt
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
コード例 #4
0
    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
コード例 #5
0
ファイル: puppet_test.py プロジェクト: bryson/salt
    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