From 9eb85c481cf651d3c4c042c3a8eecbe7ca95affe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 28 Apr 2016 08:36:56 +0200 Subject: [PATCH] [util] Use koji profile for getting RPMs from buildroot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of having a separate config option, just use the koji profile. According to release notes, this should have already been done. Signed-off-by: Lubomír Sedlář --- pungi/util.py | 10 +++++----- tests/test_util.py | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pungi/util.py b/pungi/util.py index 0522eeb1..9a584b20 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -30,6 +30,8 @@ import traceback from kobo.shortcuts import run, force_list from productmd.common import get_major_version +from .wrappers import kojiwrapper + def _doRunCommand(command, logger, rundir='/tmp', output=subprocess.PIPE, error=subprocess.PIPE, env=None): """Run a command and log the output. Error out if we get something on stderr""" @@ -306,12 +308,10 @@ def get_buildroot_rpms(compose, task_id): result = [] if task_id: # runroot - import koji - koji_url = compose.conf["pkgset_koji_url"] - koji_proxy = koji.ClientSession(koji_url) - buildroot_infos = koji_proxy.listBuildroots(taskID=task_id) + koji = kojiwrapper.KojiWrapper(compose.conf['koji_profile']) + buildroot_infos = koji.koji_proxy.listBuildroots(taskID=task_id) buildroot_info = buildroot_infos[-1] - data = koji_proxy.listRPMs(componentBuildrootID=buildroot_info["id"]) + data = koji.koji_proxy.listRPMs(componentBuildrootID=buildroot_info["id"]) for rpm_info in data: fmt = "%(nvr)s.%(arch)s" result.append(fmt % rpm_info) diff --git a/tests/test_util.py b/tests/test_util.py index 498df30d..04f5a341 100755 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -320,22 +320,22 @@ RPM_LIST = [ class TestGetBuildrootRPMs(unittest.TestCase): - @mock.patch('koji.ClientSession') - def test_get_from_koji(self, ClientSession): + @mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper') + def test_get_from_koji(self, KojiWrapper): compose = mock.Mock(conf={ - 'pkgset_koji_url': 'http://example.com/koji' + 'koji_profile': 'koji', }) - ClientSession.return_value.listBuildroots.return_value = BUILDROOT_LIST - ClientSession.return_value.listRPMs.return_value = RPM_LIST + KojiWrapper.return_value.koji_proxy.listBuildroots.return_value = BUILDROOT_LIST + KojiWrapper.return_value.koji_proxy.listRPMs.return_value = RPM_LIST rpms = util.get_buildroot_rpms(compose, 1234) - self.assertEqual(ClientSession.call_args_list, - [mock.call('http://example.com/koji')]) - self.assertEqual(ClientSession.return_value.mock_calls, - [mock.call.listBuildroots(taskID=1234), - mock.call.listRPMs(componentBuildrootID=5458481)]) + self.assertEqual(KojiWrapper.call_args_list, + [mock.call('koji')]) + self.assertEqual(KojiWrapper.return_value.mock_calls, + [mock.call.koji_proxy.listBuildroots(taskID=1234), + mock.call.koji_proxy.listRPMs(componentBuildrootID=5458481)]) self.assertItemsEqual(rpms, [ 'python3-kickstart-2.25-2.fc24.noarch',