Beispiel #1
0
    def test_module(self, open_mock, mock_subproc_popen):
        #
        # setup
        #
        self._open_mock(open_mock)

        process_mock = mock.Mock()
        attrs = {'communicate.return_value': ('ouput', 'ok'),
                 'poll.return_value': 0}
        process_mock.configure_mock(**attrs)
        mock_subproc_popen.return_value = process_mock

        template = self.useFixture(ep.PuppetExPlanDownloable()).execution_plan
        script = list(template['Scripts'].values())[0]
        self.puppet_executor.load('path',
                                  script['Options'])
        self.puppet_executor.run('test')
Beispiel #2
0
    def test_module_error(self, open_mock, mock_subproc_popen):
        #
        # setup
        #
        self._open_mock(open_mock)

        process_mock = mock.Mock()
        attrs = {
            'communicate.return_value': ('ouput', 'error'),
            'poll.return_value': 2
        }
        process_mock.configure_mock(**attrs)
        mock_subproc_popen.return_value = process_mock

        template = self.useFixture(ep.PuppetExPlanDownloable()).execution_plan
        self.puppet_executor.load('path',
                                  template['Scripts'].values()[0]['Options'])
        self.assertRaises(ex.CustomException, self.puppet_executor.run, 'test')