[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):
|
||||
rpm_info, build_info = queue_item
|
||||
rpm_path = None
|
||||
found = False
|
||||
pathinfo = self.koji_wrapper.koji_module.pathinfo
|
||||
paths = []
|
||||
for sigkey in self.sigkey_ordering:
|
||||
@ -242,25 +240,17 @@ class KojiPackageSet(PackageSetBase):
|
||||
rpm_path = os.path.join(pathinfo.build(build_info), pathinfo.signed(rpm_info, sigkey))
|
||||
paths.append(rpm_path)
|
||||
if os.path.isfile(rpm_path):
|
||||
found = True
|
||||
break
|
||||
return rpm_path
|
||||
|
||||
if not found:
|
||||
if None in self.sigkey_ordering:
|
||||
# use an unsigned copy (if allowed)
|
||||
rpm_path = os.path.join(pathinfo.build(build_info), pathinfo.rpm(rpm_info))
|
||||
paths.append(rpm_path)
|
||||
if os.path.isfile(rpm_path):
|
||||
found = True
|
||||
else:
|
||||
# or raise an exception
|
||||
raise RuntimeError("RPM %s not found for sigs: %s. Paths checked: %s"
|
||||
% (rpm_info, self.sigkey_ordering, paths))
|
||||
if None in self.sigkey_ordering:
|
||||
# use an unsigned copy (if allowed)
|
||||
rpm_path = os.path.join(pathinfo.build(build_info), pathinfo.rpm(rpm_info))
|
||||
paths.append(rpm_path)
|
||||
if os.path.isfile(rpm_path):
|
||||
return rpm_path
|
||||
|
||||
if not found:
|
||||
raise RuntimeError("Package not found: %s. Paths checked: %s"
|
||||
% (rpm_info, paths))
|
||||
return rpm_path
|
||||
raise RuntimeError("RPM %s not found for sigs: %s. Paths checked: %s"
|
||||
% (rpm_info, self.sigkey_ordering, paths))
|
||||
|
||||
def populate(self, tag, event=None, inherit=True):
|
||||
result_rpms = []
|
||||
|
@ -225,6 +225,32 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
|
||||
{'x86_64': ['rpms/bash-debuginfo@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)
|
||||
class TestMergePackageSets(PkgsetCompareMixin, unittest.TestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user