- The unittests are fixed

This commit is contained in:
Stepan Oksanichenko 2023-11-10 18:08:03 +02:00
parent 4991144a01
commit ae527a2e01
Signed by: soksanichenko
GPG Key ID: AB9983172AB1E45B
3 changed files with 7 additions and 64 deletions

View File

@ -894,69 +894,6 @@ class KojiPackageSet(PackageSetBase):
class KojiMockPackageSet(KojiPackageSet):
def __init__(
self,
name,
koji_wrapper,
sigkey_ordering,
arches=None,
logger=None,
packages=None,
allow_invalid_sigkeys=False,
populate_only_packages=False,
cache_region=None,
extra_builds=None,
extra_tasks=None,
signed_packages_retries=0,
signed_packages_wait=30,
):
"""
Creates new KojiPackageSet.
:param list sigkey_ordering: Ordered list of sigkey strings. When
getting package from Koji, KojiPackageSet tries to get the package
signed by sigkey from this list. If None or "" appears in this
list, unsigned package is used.
:param list arches: List of arches to get the packages for.
:param logging.Logger logger: Logger instance to use for logging.
:param list packages: List of package names to be used when
`allow_invalid_sigkeys` or `populate_only_packages` is set.
:param bool allow_invalid_sigkeys: When True, packages *not* listed in
the `packages` list are added to KojiPackageSet even if they have
invalid sigkey. This is useful in case Koji tag contains some
unsigned packages, but we know they won't appear in a compose.
When False, all packages in Koji tag must have valid sigkey as
defined in `sigkey_ordering`.
:param bool populate_only_packages. When True, only packages in
`packages` list are added to KojiPackageSet. This can save time
when generating compose from predefined list of packages from big
Koji tag.
When False, all packages from Koji tag are added to KojiPackageSet.
:param dogpile.cache.CacheRegion cache_region: If set, the CacheRegion
will be used to cache the list of RPMs per Koji tag, so next calls
of the KojiPackageSet.populate(...) method won't try fetching it
again.
:param list extra_builds: Extra builds NVRs to get from Koji and include
in the package set.
:param list extra_tasks: Extra RPMs defined as Koji task IDs to get from Koji
and include in the package set. Useful when building testing compose
with RPM scratch builds.
"""
super(KojiMockPackageSet, self).__init__(
name,
koji_wrapper=koji_wrapper,
sigkey_ordering=sigkey_ordering,
arches=arches,
logger=logger,
packages=packages,
allow_invalid_sigkeys=allow_invalid_sigkeys,
populate_only_packages=populate_only_packages,
cache_region=cache_region,
extra_builds=extra_builds,
extra_tasks=extra_tasks,
signed_packages_retries=signed_packages_retries,
signed_packages_wait=signed_packages_wait,
)
def _is_rpm_signed(self, rpm_path) -> bool:
ts = rpm.TransactionSet()

View File

@ -932,6 +932,8 @@ class TestReuseKojiPkgset(helpers.PungiTestCase):
"include_packages": None,
"rpms_by_arch": mock.Mock(),
"srpms_by_name": mock.Mock(),
"inherit_to_noarch": True,
"exclusive_noarch": True,
}
)
self.pkgset.old_file_cache = mock.Mock()

View File

@ -839,6 +839,7 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
super(TestAddModuleToVariantForKojiMock, self).setUp()
self.koji = mock.Mock()
self.koji.koji_module.pathinfo.typedir.return_value = "/koji"
self.compose = helpers.DummyCompose(self.topdir, {})
self.koji.koji_module.pathinfo.topdir = MMDS_DIR
files = [
"modulemd.x86_64.txt",
@ -897,7 +898,10 @@ class TestAddModuleToVariantForKojiMock(helpers.PungiTestCase):
modules=[{"name": "m1:latest-20190101:cafe", "glob": False}],
)
source_koji._add_module_to_variant(self.koji, variant, self.buildinfo)
source_koji._add_module_to_variant(
self.koji, variant, self.buildinfo, compose=self.compose
)
mod = variant.arch_mmds["x86_64"]["m1:latest:20190101:cafe"]
self.assertEqual(mod.get_NSVCA(), "m1:latest:20190101:cafe:x86_64")