[pkgset] Simplify finding RPM in koji buildroot
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
0c8eb6c0fb
commit
d7012c442a
@ -230,8 +230,6 @@ class KojiPackageSet(PackageSetBase):
|
|||||||
|
|
||||||
def get_package_path(self, queue_item):
|
def get_package_path(self, queue_item):
|
||||||
rpm_info, build_info = queue_item
|
rpm_info, build_info = queue_item
|
||||||
rpm_path = None
|
|
||||||
found = False
|
|
||||||
pathinfo = self.koji_wrapper.koji_module.pathinfo
|
pathinfo = self.koji_wrapper.koji_module.pathinfo
|
||||||
paths = []
|
paths = []
|
||||||
for sigkey in self.sigkey_ordering:
|
for sigkey in self.sigkey_ordering:
|
||||||
@ -242,26 +240,18 @@ class KojiPackageSet(PackageSetBase):
|
|||||||
rpm_path = os.path.join(pathinfo.build(build_info), pathinfo.signed(rpm_info, sigkey))
|
rpm_path = os.path.join(pathinfo.build(build_info), pathinfo.signed(rpm_info, sigkey))
|
||||||
paths.append(rpm_path)
|
paths.append(rpm_path)
|
||||||
if os.path.isfile(rpm_path):
|
if os.path.isfile(rpm_path):
|
||||||
found = True
|
return rpm_path
|
||||||
break
|
|
||||||
|
|
||||||
if not found:
|
|
||||||
if None in self.sigkey_ordering:
|
if None in self.sigkey_ordering:
|
||||||
# use an unsigned copy (if allowed)
|
# use an unsigned copy (if allowed)
|
||||||
rpm_path = os.path.join(pathinfo.build(build_info), pathinfo.rpm(rpm_info))
|
rpm_path = os.path.join(pathinfo.build(build_info), pathinfo.rpm(rpm_info))
|
||||||
paths.append(rpm_path)
|
paths.append(rpm_path)
|
||||||
if os.path.isfile(rpm_path):
|
if os.path.isfile(rpm_path):
|
||||||
found = True
|
return rpm_path
|
||||||
else:
|
|
||||||
# or raise an exception
|
|
||||||
raise RuntimeError("RPM %s not found for sigs: %s. Paths checked: %s"
|
raise RuntimeError("RPM %s not found for sigs: %s. Paths checked: %s"
|
||||||
% (rpm_info, self.sigkey_ordering, paths))
|
% (rpm_info, self.sigkey_ordering, paths))
|
||||||
|
|
||||||
if not found:
|
|
||||||
raise RuntimeError("Package not found: %s. Paths checked: %s"
|
|
||||||
% (rpm_info, paths))
|
|
||||||
return rpm_path
|
|
||||||
|
|
||||||
def populate(self, tag, event=None, inherit=True):
|
def populate(self, tag, event=None, inherit=True):
|
||||||
result_rpms = []
|
result_rpms = []
|
||||||
result_srpms = []
|
result_srpms = []
|
||||||
|
@ -225,6 +225,32 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
|
|||||||
{'x86_64': ['rpms/bash-debuginfo@4.3.42@4.fc24@x86_64',
|
{'x86_64': ['rpms/bash-debuginfo@4.3.42@4.fc24@x86_64',
|
||||||
'signed/cafebabe/bash@4.3.42@4.fc24@x86_64']})
|
'signed/cafebabe/bash@4.3.42@4.fc24@x86_64']})
|
||||||
|
|
||||||
|
def test_can_not_find_signed_package(self):
|
||||||
|
pkgset = pkgsets.KojiPackageSet(self.koji_wrapper, ['cafebabe'], arches=['x86_64'])
|
||||||
|
|
||||||
|
with self.assertRaises(RuntimeError) as ctx:
|
||||||
|
pkgset.populate('f25')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
self.koji_wrapper.koji_proxy.mock_calls,
|
||||||
|
[mock.call.listTaggedRPMS('f25', event=None, inherit=True, latest=True)])
|
||||||
|
|
||||||
|
self.assertRegexpMatches(str(ctx.exception),
|
||||||
|
r'^RPM .+ not found for sigs: .+ Paths checked: .+$')
|
||||||
|
|
||||||
|
def test_can_not_find_any_package(self):
|
||||||
|
pkgset = pkgsets.KojiPackageSet(self.koji_wrapper, ['cafebabe', None], arches=['x86_64'])
|
||||||
|
|
||||||
|
with self.assertRaises(RuntimeError) as ctx:
|
||||||
|
pkgset.populate('f25')
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
self.koji_wrapper.koji_proxy.mock_calls,
|
||||||
|
[mock.call.listTaggedRPMS('f25', event=None, inherit=True, latest=True)])
|
||||||
|
|
||||||
|
self.assertRegexpMatches(str(ctx.exception),
|
||||||
|
r'^RPM .+ not found for sigs: .+ Paths checked: .+$')
|
||||||
|
|
||||||
|
|
||||||
@mock.patch('kobo.pkgset.FileCache', new=MockFileCache)
|
@mock.patch('kobo.pkgset.FileCache', new=MockFileCache)
|
||||||
class TestMergePackageSets(PkgsetCompareMixin, unittest.TestCase):
|
class TestMergePackageSets(PkgsetCompareMixin, unittest.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user