def test_chef_no_berkshelf(self): """It tests the cookbook path if Berkshelf is not enabled""" template = self.useFixture(ep.ExPlanDownloable()).execution_plan self.chef_executor.load('path', template['Scripts'].values()[0]['Options']) cookbook_path = self.chef_executor._create_cookbook_path('cookbook') self.assertEqual(cookbook_path, os.path.abspath('path'))
def test_cookbook(self, mock_isdir, mock_exist, open_mock, mock_subproc_popen): """It tests chef executor.""" self._open_mock(open_mock) mock_exist.return_value = True mock_isdir.return_value = True process_mock = mock.Mock() attrs = {'communicate.return_value': ('output', 'ok'), 'poll.return_value': 0} process_mock.configure_mock(**attrs) mock_subproc_popen.return_value = process_mock template = self.useFixture(ep.ExPlanDownloable()).execution_plan script = list(template['Scripts'].values()) self.chef_executor.load('path', script[0]['Options']) self.chef_executor.run('test')
def test_cookbook_error(self, mock_isdir, mock_exist, open_mock, mock_subproc_popen): """It tests chef executor with error in the request.""" self._open_mock(open_mock) mock_exist.return_value = True mock_isdir.return_value = True process_mock = mock.Mock() attrs = { 'communicate.return_value': ('output', 'error'), 'poll.return_value': 2 } process_mock.configure_mock(**attrs) mock_subproc_popen.return_value = process_mock template = self.useFixture(ep.ExPlanDownloable()).execution_plan self.chef_executor.load('path', template['Scripts'].values()[0]['Options']) self.assertRaises(ex.CustomException, self.chef_executor.run, 'test')
def test_verify_execution_plan_downloable(self): template = self.useFixture(ep.ExPlanDownloable()).execution_plan self.agent._verify_plan(template)