2018-06-22 06:58:54 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from collections import namedtuple
|
|
|
|
import copy
|
|
|
|
import mock
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
import six
|
|
|
|
|
2018-06-22 06:58:54 +00:00
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
|
|
|
|
|
|
|
|
from pungi.phases.gather.methods import method_hybrid as hybrid
|
2019-08-01 09:19:51 +00:00
|
|
|
from pungi.phases.pkgset.common import MaterializedPackageSet as PkgSet
|
2018-06-22 06:58:54 +00:00
|
|
|
from tests import helpers
|
|
|
|
|
|
|
|
|
|
|
|
MockPkg = namedtuple(
|
|
|
|
"MockPkg", ["name", "version", "release", "epoch", "sourcerpm", "file_path", "arch"]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class NamedMock(mock.Mock):
|
|
|
|
def __init__(self, name=None, **kwargs):
|
|
|
|
super(NamedMock, self).__init__(**kwargs)
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
|
|
|
|
class TestMethodHybrid(helpers.PungiTestCase):
|
2019-11-18 10:17:37 +00:00
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.temp_dir")
|
2018-07-17 12:29:52 +00:00
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.CompsWrapper")
|
2018-06-22 06:58:54 +00:00
|
|
|
@mock.patch("pungi.phases.gather.get_lookaside_repos")
|
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.expand_groups")
|
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.expand_packages")
|
2019-06-26 13:09:25 +00:00
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.get_platform")
|
2019-11-18 10:17:37 +00:00
|
|
|
def test_call_method(self, gp, ep, eg, glr, CW, td):
|
2018-06-22 06:58:54 +00:00
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
m = hybrid.GatherMethodHybrid(compose)
|
2018-10-03 10:19:33 +00:00
|
|
|
m.run_solver = mock.Mock(return_value=(mock.Mock(), mock.Mock()))
|
2018-06-22 06:58:54 +00:00
|
|
|
pkg = MockPkg(
|
|
|
|
name="pkg",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=3,
|
|
|
|
sourcerpm=None,
|
|
|
|
file_path=None,
|
|
|
|
)
|
2018-07-17 12:29:52 +00:00
|
|
|
CW.return_value.get_langpacks.return_value = {"glibc": "glibc-langpack-%s"}
|
2018-06-22 06:58:54 +00:00
|
|
|
eg.return_value = ["foo", "bar"]
|
2019-08-01 09:19:51 +00:00
|
|
|
package_sets = [
|
|
|
|
PkgSet({"x86_64": mock.Mock(rpms_by_arch={"x86_64": [pkg]})}, {})
|
|
|
|
]
|
2018-06-22 06:58:54 +00:00
|
|
|
arch = "x86_64"
|
|
|
|
variant = compose.variants["Server"]
|
|
|
|
|
2019-01-29 11:43:40 +00:00
|
|
|
res = m(
|
|
|
|
arch,
|
|
|
|
variant,
|
|
|
|
package_sets,
|
|
|
|
set(["pkg"]),
|
|
|
|
["standard"],
|
|
|
|
prepopulate=["prep.noarch"],
|
|
|
|
)
|
2018-06-22 06:58:54 +00:00
|
|
|
|
|
|
|
self.assertEqual(res, ep.return_value)
|
2019-06-26 13:09:25 +00:00
|
|
|
self.assertEqual(gp.call_args_list, [mock.call(compose, variant, arch)])
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
m.run_solver.call_args_list,
|
2019-01-29 11:43:40 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
variant,
|
|
|
|
arch,
|
|
|
|
set(["pkg", "foo", "bar", ("prep", "noarch")]),
|
2019-06-26 13:09:25 +00:00
|
|
|
gp.return_value,
|
2019-01-29 11:43:40 +00:00
|
|
|
[],
|
2019-11-18 10:17:37 +00:00
|
|
|
cache_dir=td.return_value.__enter__.return_value,
|
2019-01-29 11:43:40 +00:00
|
|
|
)
|
|
|
|
],
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
2019-11-18 10:17:37 +00:00
|
|
|
self.assertIn(
|
|
|
|
[mock.call(prefix="fus-cache-Test-20151203.0.t-Server-x86_64-")],
|
|
|
|
td.mock_calls,
|
|
|
|
)
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
ep.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
{"pkg-3:1-2.x86_64": pkg},
|
|
|
|
glr.return_value,
|
2018-10-03 10:19:33 +00:00
|
|
|
m.run_solver.return_value[0],
|
2019-02-08 09:10:41 +00:00
|
|
|
filter_packages=[],
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
eg.call_args_list,
|
|
|
|
[mock.call(compose, arch, variant, ["standard"], set_pkg_arch=False)],
|
|
|
|
)
|
2018-07-17 12:29:52 +00:00
|
|
|
self.assertEqual(
|
|
|
|
CW.mock_calls,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
os.path.join(
|
|
|
|
self.topdir, "work/x86_64/comps/comps-Server.x86_64.xml"
|
|
|
|
)
|
|
|
|
),
|
|
|
|
mock.call().get_langpacks(),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.CompsWrapper")
|
|
|
|
def test_prepare_langpacks(self, CW):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
CW.return_value.get_langpacks.return_value = {"foo": "foo-%s"}
|
|
|
|
m = hybrid.GatherMethodHybrid(compose)
|
2019-07-25 08:15:14 +00:00
|
|
|
m.package_sets = [
|
2019-08-01 09:19:51 +00:00
|
|
|
PkgSet(
|
|
|
|
{
|
|
|
|
"x86_64": mock.Mock(
|
|
|
|
rpms_by_arch={
|
|
|
|
"x86_64": [
|
|
|
|
MockPkg(
|
|
|
|
name="foo",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=0,
|
|
|
|
sourcerpm=None,
|
|
|
|
file_path=None,
|
|
|
|
),
|
|
|
|
MockPkg(
|
|
|
|
name="foo-en",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=0,
|
|
|
|
sourcerpm=None,
|
|
|
|
file_path=None,
|
|
|
|
),
|
|
|
|
MockPkg(
|
|
|
|
name="foo-devel",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=0,
|
|
|
|
sourcerpm=None,
|
|
|
|
file_path=None,
|
|
|
|
),
|
|
|
|
MockPkg(
|
|
|
|
name="foo-debuginfo",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=0,
|
|
|
|
sourcerpm=None,
|
|
|
|
file_path=None,
|
|
|
|
),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
)
|
2019-07-25 08:15:14 +00:00
|
|
|
]
|
2018-07-17 12:29:52 +00:00
|
|
|
m.prepare_langpacks("x86_64", compose.variants["Server"])
|
|
|
|
|
|
|
|
self.assertEqual(m.langpacks, {"foo": set(["foo-en"])})
|
2018-06-22 06:58:54 +00:00
|
|
|
|
2018-09-05 13:00:01 +00:00
|
|
|
def test_expand_list(self):
|
|
|
|
compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
m = hybrid.GatherMethodHybrid(compose)
|
2018-10-23 06:29:45 +00:00
|
|
|
m.arch = "x86_64"
|
2019-07-25 08:15:14 +00:00
|
|
|
m.package_sets = [
|
2019-08-01 09:19:51 +00:00
|
|
|
PkgSet(
|
|
|
|
{
|
|
|
|
"x86_64": mock.Mock(
|
|
|
|
rpms_by_arch={
|
|
|
|
"x86_64": [
|
|
|
|
MockPkg(
|
|
|
|
name="foo",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=0,
|
|
|
|
sourcerpm=None,
|
|
|
|
file_path=None,
|
|
|
|
),
|
|
|
|
MockPkg(
|
|
|
|
name="foo-en",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=0,
|
|
|
|
sourcerpm=None,
|
|
|
|
file_path=None,
|
|
|
|
),
|
|
|
|
MockPkg(
|
|
|
|
name="bar",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=0,
|
|
|
|
sourcerpm=None,
|
|
|
|
file_path=None,
|
|
|
|
),
|
|
|
|
]
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
)
|
2019-07-25 08:15:14 +00:00
|
|
|
]
|
2018-10-23 06:29:45 +00:00
|
|
|
expanded = m.expand_list(["foo*"])
|
2018-09-05 13:00:01 +00:00
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, [p.name for p in expanded], ["foo", "foo-en"])
|
2018-09-05 13:00:01 +00:00
|
|
|
|
2018-06-22 06:58:54 +00:00
|
|
|
|
|
|
|
class MockModule(object):
|
|
|
|
def __init__(
|
|
|
|
self, name, platform=None, stream=None, version=None, context=None, rpms=None
|
|
|
|
):
|
|
|
|
self.name = name
|
|
|
|
self.platform = platform
|
|
|
|
self.stream = stream
|
|
|
|
self.version = version
|
|
|
|
self.context = context
|
|
|
|
self.rpms = rpms or ["pkg-1.0-1.x86_64"]
|
|
|
|
|
|
|
|
def get_name(self):
|
|
|
|
return self.name
|
|
|
|
|
2019-07-01 10:11:39 +00:00
|
|
|
def get_module_name(self):
|
2018-06-22 06:58:54 +00:00
|
|
|
return self.name
|
|
|
|
|
2019-07-01 10:11:39 +00:00
|
|
|
def get_stream_name(self):
|
2018-06-22 06:58:54 +00:00
|
|
|
return self.stream
|
|
|
|
|
2019-07-01 10:11:39 +00:00
|
|
|
def get_version(self):
|
2018-06-22 06:58:54 +00:00
|
|
|
return self.version
|
|
|
|
|
2019-07-01 10:11:39 +00:00
|
|
|
def get_context(self):
|
2018-06-22 06:58:54 +00:00
|
|
|
return self.context
|
|
|
|
|
2019-07-01 10:11:39 +00:00
|
|
|
def get_dependencies(self):
|
|
|
|
def get_runtime_streams(platform):
|
|
|
|
assert platform == "platform"
|
|
|
|
return [self.platform]
|
|
|
|
return [mock.Mock(get_runtime_streams=get_runtime_streams)]
|
2018-06-22 06:58:54 +00:00
|
|
|
|
|
|
|
def get_rpm_artifacts(self):
|
2019-07-01 10:11:39 +00:00
|
|
|
return self.rpms
|
2018-06-22 06:58:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HelperMixin(object):
|
|
|
|
def _repo(self, name):
|
|
|
|
return os.path.join(self.compose.topdir, "work/x86_64/%s" % name)
|
|
|
|
|
|
|
|
|
2019-06-26 13:09:25 +00:00
|
|
|
class TestGetPlatform(HelperMixin, helpers.PungiTestCase):
|
2018-06-22 06:58:54 +00:00
|
|
|
def setUp(self):
|
2019-06-26 13:09:25 +00:00
|
|
|
super(TestGetPlatform, self).setUp()
|
2018-06-22 06:58:54 +00:00
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
self.variant = self.compose.variants["Server"]
|
|
|
|
|
2019-06-26 13:09:25 +00:00
|
|
|
def test_no_modules(self):
|
|
|
|
plat = hybrid.get_platform(self.compose, self.variant, "x86_64")
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertIsNone(plat)
|
|
|
|
|
2019-06-26 13:09:25 +00:00
|
|
|
def test_more_than_one_platform(self):
|
2018-06-22 06:58:54 +00:00
|
|
|
self.variant.arch_mmds["x86_64"] = {
|
|
|
|
"mod:1": MockModule("mod", platform="f29"),
|
|
|
|
"mod:2": MockModule("mod", platform="f30"),
|
|
|
|
}
|
|
|
|
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2019-06-26 13:09:25 +00:00
|
|
|
hybrid.get_platform(self.compose, self.variant, "x86_64")
|
2018-06-22 06:58:54 +00:00
|
|
|
|
|
|
|
self.assertIn("conflicting requests for platform", str(ctx.exception))
|
|
|
|
|
|
|
|
|
|
|
|
class ModifiedMagicMock(mock.MagicMock):
|
|
|
|
"""Like MagicMock, but remembers original values or mutable arguments."""
|
|
|
|
|
|
|
|
def _mock_call(_mock_self, *args, **kwargs):
|
|
|
|
return super(ModifiedMagicMock, _mock_self)._mock_call(
|
|
|
|
*copy.deepcopy(args), **copy.deepcopy(kwargs)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2018-10-12 12:50:46 +00:00
|
|
|
@mock.patch("pungi.wrappers.fus.write_config")
|
2018-06-22 06:58:54 +00:00
|
|
|
@mock.patch("pungi.wrappers.fus.parse_output")
|
|
|
|
@mock.patch("pungi.wrappers.fus.get_cmd", new_callable=ModifiedMagicMock)
|
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.run")
|
|
|
|
class TestRunSolver(HelperMixin, helpers.PungiTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(TestRunSolver, self).setUp()
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
self.phase = hybrid.GatherMethodHybrid(self.compose)
|
|
|
|
self.phase.multilib_methods = []
|
2019-02-27 13:30:01 +00:00
|
|
|
self.phase.arch = "x86_64"
|
2019-08-01 09:19:51 +00:00
|
|
|
self.phase.variant = self.compose.variants["Server"]
|
|
|
|
self.phase.package_sets = [
|
|
|
|
PkgSet(
|
|
|
|
{"x86_64": mock.Mock(rpms_by_arch={"x86_64": []})},
|
|
|
|
{"x86_64": "/path/for/p1"},
|
|
|
|
)
|
|
|
|
]
|
2018-06-22 06:58:54 +00:00
|
|
|
self.logfile1 = os.path.join(
|
|
|
|
self.compose.topdir, "logs/x86_64/hybrid-depsolver-Server-iter-1.x86_64.log"
|
|
|
|
)
|
|
|
|
self.logfile2 = os.path.join(
|
|
|
|
self.compose.topdir, "logs/x86_64/hybrid-depsolver-Server-iter-2.x86_64.log"
|
|
|
|
)
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config1 = os.path.join(
|
|
|
|
self.compose.topdir, "work/x86_64/fus/Server-solvables-1.x86_64.conf"
|
|
|
|
)
|
|
|
|
self.config2 = os.path.join(
|
|
|
|
self.compose.topdir, "work/x86_64/fus/Server-solvables-2.x86_64.conf"
|
|
|
|
)
|
2018-06-22 06:58:54 +00:00
|
|
|
|
2018-10-12 12:50:46 +00:00
|
|
|
def test_with_modules(self, run, gc, po, wc):
|
2018-07-17 12:29:52 +00:00
|
|
|
self.compose.has_comps = False
|
2018-06-22 06:58:54 +00:00
|
|
|
self.compose.variants["Server"].arch_mmds["x86_64"] = {
|
|
|
|
"mod:master": mock.Mock(
|
2019-07-01 10:11:39 +00:00
|
|
|
get_module_name=mock.Mock(return_value="mod"),
|
|
|
|
get_stream_name=mock.Mock(return_value="master"),
|
|
|
|
get_version=mock.Mock(return_value="ver"),
|
|
|
|
get_context=mock.Mock(return_value="ctx"),
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
}
|
2019-02-27 13:30:01 +00:00
|
|
|
po.return_value = ([], ["m1"])
|
2018-06-22 06:58:54 +00:00
|
|
|
|
|
|
|
res = self.phase.run_solver(
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
[],
|
|
|
|
platform="pl",
|
2019-02-08 09:10:41 +00:00
|
|
|
filter_packages=[("foo", None)],
|
2019-11-18 10:17:37 +00:00
|
|
|
cache_dir="/cache",
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(res[0], set())
|
|
|
|
self.assertEqual(res[1], set(["m1"]))
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(po.call_args_list, [mock.call(self.logfile1)])
|
|
|
|
self.assertEqual(
|
|
|
|
run.call_args_list,
|
2018-09-26 12:13:35 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY
|
|
|
|
)
|
|
|
|
],
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
2018-10-12 12:50:46 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wc.call_args_list, [mock.call(self.config1, ["mod:master"], [])],
|
|
|
|
)
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config1,
|
2018-06-22 06:58:54 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-06-22 06:58:54 +00:00
|
|
|
[],
|
|
|
|
platform="pl",
|
2019-02-08 09:10:41 +00:00
|
|
|
filter_packages=[("foo", None)],
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-10-12 12:50:46 +00:00
|
|
|
def test_with_modules_with_devel(self, run, gc, po, wc):
|
2018-10-02 09:09:12 +00:00
|
|
|
self.compose.has_comps = False
|
|
|
|
self.compose.variants["Server"].arch_mmds["x86_64"] = {
|
|
|
|
"mod:master": mock.Mock(
|
2019-07-01 10:11:39 +00:00
|
|
|
get_module_name=mock.Mock(return_value="mod"),
|
|
|
|
get_stream_name=mock.Mock(return_value="master"),
|
|
|
|
get_version=mock.Mock(return_value="ver"),
|
|
|
|
get_context=mock.Mock(return_value="ctx"),
|
2018-10-02 09:09:12 +00:00
|
|
|
),
|
|
|
|
"mod-devel:master": mock.Mock(
|
2019-07-01 10:11:39 +00:00
|
|
|
get_module_name=mock.Mock(return_value="mod-devel"),
|
|
|
|
get_stream_name=mock.Mock(return_value="master"),
|
|
|
|
get_version=mock.Mock(return_value="ver"),
|
|
|
|
get_context=mock.Mock(return_value="ctx"),
|
2018-10-02 09:09:12 +00:00
|
|
|
),
|
|
|
|
}
|
2019-02-27 13:30:01 +00:00
|
|
|
po.return_value = ([("p-1-1", "x86_64", frozenset())], ["m1"])
|
|
|
|
self.phase.packages = {"p-1-1.x86_64": mock.Mock()}
|
2018-10-02 09:09:12 +00:00
|
|
|
|
|
|
|
res = self.phase.run_solver(
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
[],
|
|
|
|
platform="pl",
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=["foo"],
|
2019-11-18 10:17:37 +00:00
|
|
|
cache_dir="/cache",
|
2018-10-02 09:09:12 +00:00
|
|
|
)
|
|
|
|
|
2019-02-27 13:30:01 +00:00
|
|
|
self.assertEqual(res, (set([("p-1-1", "x86_64", frozenset())]), set(["m1"])))
|
2018-10-02 09:09:12 +00:00
|
|
|
self.assertEqual(po.call_args_list, [mock.call(self.logfile1)])
|
|
|
|
self.assertEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2018-10-12 12:50:46 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wc.call_args_list,
|
|
|
|
[mock.call(self.config1, ["mod-devel:master", "mod:master"], [])],
|
|
|
|
)
|
2018-10-02 09:09:12 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config1,
|
2018-10-02 09:09:12 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-10-02 09:09:12 +00:00
|
|
|
[],
|
|
|
|
platform="pl",
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=["foo"],
|
2018-10-02 09:09:12 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-10-12 12:50:46 +00:00
|
|
|
def test_with_comps(self, run, gc, po, wc):
|
2019-02-27 13:30:01 +00:00
|
|
|
self.phase.packages = {"pkg-1.0-1.x86_64": mock.Mock()}
|
|
|
|
self.phase.debuginfo = {"x86_64": {}}
|
|
|
|
po.return_value = ([("pkg-1.0-1", "x86_64", frozenset())], [])
|
2018-06-22 06:58:54 +00:00
|
|
|
res = self.phase.run_solver(
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
[("pkg", None)],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=[],
|
2019-11-18 10:17:37 +00:00
|
|
|
cache_dir="/cache",
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, res[0], po.return_value[0])
|
|
|
|
self.assertEqual(res[1], set())
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(po.call_args_list, [mock.call(self.logfile1)])
|
|
|
|
self.assertEqual(
|
|
|
|
run.call_args_list,
|
2018-09-26 12:13:35 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY
|
|
|
|
)
|
|
|
|
],
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
2018-10-12 12:50:46 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wc.call_args_list, [mock.call(self.config1, [], ["pkg"])],
|
|
|
|
)
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gc.call_args_list,
|
2018-10-16 10:29:00 +00:00
|
|
|
[
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config1,
|
2018-10-16 10:29:00 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-10-16 10:29:00 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
|
|
|
filter_packages=[],
|
|
|
|
)
|
|
|
|
],
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
|
2019-02-27 13:30:01 +00:00
|
|
|
def test_with_comps_with_debuginfo(self, run, gc, po, wc):
|
|
|
|
dbg1 = NamedMock(name="pkg-debuginfo", arch="x86_64", sourcerpm="pkg.src.rpm")
|
|
|
|
dbg2 = NamedMock(name="pkg-debuginfo", arch="x86_64", sourcerpm="x.src.rpm")
|
|
|
|
self.phase.packages = {
|
|
|
|
"pkg-1.0-1.x86_64": NamedMock(
|
|
|
|
name="pkg", arch="x86_64", rpm_sourcerpm="pkg.src.rpm"
|
|
|
|
),
|
|
|
|
"pkg-debuginfo-1.0-1.x86_64": dbg1,
|
|
|
|
"pkg-debuginfo-1.0-2.x86_64": dbg2,
|
|
|
|
}
|
|
|
|
self.phase.debuginfo = {
|
|
|
|
"x86_64": {
|
|
|
|
"pkg-debuginfo": [dbg1, dbg2],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
po.side_effect = [
|
|
|
|
([("pkg-1.0-1", "x86_64", frozenset())], []),
|
|
|
|
([("pkg-debuginfo-1.0-1", "x86_64", frozenset())], []),
|
|
|
|
]
|
|
|
|
res = self.phase.run_solver(
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
[("pkg", None)],
|
|
|
|
platform=None,
|
|
|
|
filter_packages=[],
|
2019-11-18 10:17:37 +00:00
|
|
|
cache_dir="/cache",
|
2019-02-27 13:30:01 +00:00
|
|
|
)
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2019-02-27 13:30:01 +00:00
|
|
|
res[0],
|
|
|
|
[
|
|
|
|
("pkg-1.0-1", "x86_64", frozenset()),
|
|
|
|
("pkg-debuginfo-1.0-1", "x86_64", frozenset()),
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(res[1], set())
|
2019-02-27 13:30:01 +00:00
|
|
|
self.assertEqual(
|
|
|
|
po.call_args_list, [mock.call(self.logfile1), mock.call(self.logfile2)]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile2, show_cmd=True, env=mock.ANY
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
wc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(self.config1, [], ["pkg"]),
|
|
|
|
mock.call(self.config2, [], ["pkg-debuginfo.x86_64"]),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
gc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
|
|
|
self.config1,
|
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2019-02-27 13:30:01 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
|
|
|
filter_packages=[],
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
self.config2,
|
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2019-02-27 13:30:01 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
|
|
|
filter_packages=[],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-10-12 12:50:46 +00:00
|
|
|
def test_with_langpacks(self, run, gc, po, wc):
|
2018-07-17 12:29:52 +00:00
|
|
|
self.phase.langpacks = {"pkg": set(["pkg-en"])}
|
2019-02-27 13:30:01 +00:00
|
|
|
final = [
|
|
|
|
("pkg-1.0-1", "x86_64", frozenset()),
|
|
|
|
("pkg-en-1.0-1", "noarch", frozenset()),
|
|
|
|
]
|
|
|
|
po.side_effect = [([("pkg-1.0-1", "x86_64", frozenset())], []), (final, [])]
|
|
|
|
self.phase.packages = {
|
|
|
|
"pkg-1.0-1.x86_64": mock.Mock(),
|
|
|
|
"pkg-en-1.0-1.noarch": mock.Mock(),
|
|
|
|
}
|
2018-07-17 12:29:52 +00:00
|
|
|
|
|
|
|
res = self.phase.run_solver(
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
[("pkg", None)],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=["foo"],
|
2019-11-18 10:17:37 +00:00
|
|
|
cache_dir="/cache",
|
2018-07-17 12:29:52 +00:00
|
|
|
)
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(self, res[0], final)
|
|
|
|
self.assertEqual(res[1], set())
|
2018-07-17 12:29:52 +00:00
|
|
|
self.assertEqual(
|
|
|
|
po.call_args_list, [mock.call(self.logfile1), mock.call(self.logfile2)]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[
|
2018-09-26 12:13:35 +00:00
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile2, show_cmd=True, env=mock.ANY
|
|
|
|
),
|
2018-07-17 12:29:52 +00:00
|
|
|
],
|
|
|
|
)
|
2018-10-12 12:50:46 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(self.config1, [], ["pkg"]),
|
2019-02-27 13:30:01 +00:00
|
|
|
mock.call(self.config2, [], ["pkg-en"]),
|
2018-10-12 12:50:46 +00:00
|
|
|
],
|
|
|
|
)
|
2018-07-17 12:29:52 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config1,
|
2018-10-16 10:29:00 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-10-16 10:29:00 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
|
|
|
filter_packages=["foo"],
|
2018-07-17 12:29:52 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config2,
|
2018-07-17 12:29:52 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-07-17 12:29:52 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=["foo"],
|
2018-07-17 12:29:52 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2018-06-22 06:58:54 +00:00
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.cr")
|
2018-10-12 12:50:46 +00:00
|
|
|
def test_multilib_devel(self, cr, run, gc, po, wc):
|
2018-06-22 06:58:54 +00:00
|
|
|
self.phase.arch = "x86_64"
|
|
|
|
self.phase.multilib_methods = ["devel"]
|
|
|
|
self.phase.multilib = mock.Mock()
|
|
|
|
self.phase.multilib.is_multilib.side_effect = (
|
|
|
|
lambda pkg: pkg.name == "pkg-devel"
|
|
|
|
)
|
|
|
|
self.phase.valid_arches = ["x86_64", "i686", "noarch"]
|
|
|
|
cr.Metadata.return_value.keys.return_value = []
|
|
|
|
self.phase.package_maps = {
|
|
|
|
"x86_64": {
|
|
|
|
"pkg-devel-1.0-1.x86_64": NamedMock(name="pkg-devel"),
|
|
|
|
"pkg-devel-1.0-1.i686": NamedMock(name="pkg-devel"),
|
|
|
|
"foo-1.0-1.x86_64": NamedMock(name="foo"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.phase.packages = self.phase.package_maps["x86_64"]
|
2019-02-27 13:30:01 +00:00
|
|
|
self.phase.debuginfo = {"x86_64": {}}
|
2018-06-22 06:58:54 +00:00
|
|
|
po.side_effect = [
|
2019-02-27 13:30:01 +00:00
|
|
|
(
|
|
|
|
[
|
|
|
|
("pkg-devel-1.0-1", "x86_64", frozenset()),
|
|
|
|
("foo-1.0-1", "x86_64", frozenset())
|
|
|
|
],
|
|
|
|
frozenset()),
|
|
|
|
(
|
|
|
|
[
|
|
|
|
("pkg-devel-1.0-1", "i686", frozenset()),
|
|
|
|
],
|
|
|
|
[],
|
|
|
|
),
|
2018-06-22 06:58:54 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
res = self.phase.run_solver(
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
[("pkg-devel", None), ("foo", None)],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=[],
|
2019-11-18 10:17:37 +00:00
|
|
|
cache_dir="/cache",
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2019-02-27 13:30:01 +00:00
|
|
|
res[0],
|
|
|
|
[
|
|
|
|
("pkg-devel-1.0-1", "x86_64", frozenset()),
|
|
|
|
("foo-1.0-1", "x86_64", frozenset()),
|
|
|
|
("pkg-devel-1.0-1", "i686", frozenset()),
|
|
|
|
]
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(res[1], set())
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
po.call_args_list, [mock.call(self.logfile1), mock.call(self.logfile2)]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[
|
2018-09-26 12:13:35 +00:00
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile2, show_cmd=True, env=mock.ANY
|
|
|
|
),
|
2018-06-22 06:58:54 +00:00
|
|
|
],
|
|
|
|
)
|
2018-10-12 12:50:46 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(self.config1, [], ["foo", "pkg-devel"]),
|
2019-02-27 13:30:01 +00:00
|
|
|
mock.call(self.config2, [], ["pkg-devel.i686"]),
|
2018-10-12 12:50:46 +00:00
|
|
|
],
|
|
|
|
)
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config1,
|
2018-06-22 06:58:54 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-06-22 06:58:54 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=[],
|
2018-06-22 06:58:54 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config2,
|
2018-06-22 06:58:54 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-06-22 06:58:54 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=[],
|
2018-06-22 06:58:54 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.cr")
|
2018-10-12 12:50:46 +00:00
|
|
|
def test_multilib_runtime(self, cr, run, gc, po, wc):
|
2018-06-22 06:58:54 +00:00
|
|
|
packages = {
|
|
|
|
"abc": NamedMock(
|
|
|
|
name="foo",
|
|
|
|
epoch=None,
|
|
|
|
version="1.0",
|
|
|
|
release="1",
|
|
|
|
arch="x86_64",
|
|
|
|
provides=[("/usr/lib/libfoo.1.so.1", None, None)],
|
|
|
|
),
|
|
|
|
"def": NamedMock(
|
|
|
|
name="foo",
|
|
|
|
epoch=None,
|
|
|
|
version="1.0",
|
|
|
|
release="1",
|
|
|
|
arch="i686",
|
|
|
|
provides=[("/usr/lib/libfoo.1.so.1", None, None)],
|
|
|
|
),
|
|
|
|
"ghi": NamedMock(
|
|
|
|
name="pkg-devel",
|
|
|
|
epoch=None,
|
|
|
|
version="1.0",
|
|
|
|
release="1",
|
|
|
|
arch="x86_64",
|
|
|
|
provides=[],
|
|
|
|
),
|
|
|
|
}
|
|
|
|
cr.Metadata.return_value.keys.return_value = packages.keys()
|
|
|
|
cr.Metadata.return_value.get.side_effect = lambda key: packages[key]
|
|
|
|
|
|
|
|
self.phase.multilib_methods = ["runtime"]
|
|
|
|
self.phase.multilib = mock.Mock()
|
|
|
|
self.phase.multilib.is_multilib.side_effect = lambda pkg: pkg.name == "foo"
|
|
|
|
self.phase.valid_arches = ["x86_64", "i686", "noarch"]
|
|
|
|
self.phase.arch = "x86_64"
|
|
|
|
self.phase.package_maps = {
|
|
|
|
"x86_64": {
|
|
|
|
"pkg-devel-1.0-1.x86_64": mock.Mock(),
|
|
|
|
"pkg-devel-1.0-1.i686": mock.Mock(),
|
|
|
|
"foo-1.0-1.x86_64": mock.Mock(),
|
|
|
|
"foo-1.0-1.i686": mock.Mock(),
|
|
|
|
}
|
|
|
|
}
|
2019-02-27 13:30:01 +00:00
|
|
|
self.phase.debuginfo = {"x86_64": {}}
|
2018-06-22 06:58:54 +00:00
|
|
|
po.side_effect = [
|
2019-02-27 13:30:01 +00:00
|
|
|
(
|
|
|
|
[
|
|
|
|
("pkg-devel-1.0-1", "x86_64", frozenset()),
|
|
|
|
("foo-1.0-1", "x86_64", frozenset())
|
|
|
|
],
|
|
|
|
[],
|
|
|
|
),
|
|
|
|
(
|
|
|
|
[
|
|
|
|
("foo-1.0-1", "i686", frozenset()),
|
|
|
|
],
|
|
|
|
[],
|
|
|
|
),
|
2018-06-22 06:58:54 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
res = self.phase.run_solver(
|
|
|
|
self.compose.variants["Server"],
|
|
|
|
"x86_64",
|
|
|
|
[("pkg-devel", None), ("foo", None)],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=[],
|
2019-11-18 10:17:37 +00:00
|
|
|
cache_dir="/cache",
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2019-02-27 13:30:01 +00:00
|
|
|
res[0],
|
|
|
|
[
|
|
|
|
("pkg-devel-1.0-1", "x86_64", frozenset()),
|
|
|
|
("foo-1.0-1", "x86_64", frozenset()),
|
|
|
|
("foo-1.0-1", "i686", frozenset()),
|
|
|
|
],
|
|
|
|
)
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(res[1], set())
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
po.call_args_list, [mock.call(self.logfile1), mock.call(self.logfile2)]
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
run.call_args_list,
|
|
|
|
[
|
2018-09-26 12:13:35 +00:00
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile1, show_cmd=True, env=mock.ANY
|
|
|
|
),
|
|
|
|
mock.call(
|
|
|
|
gc.return_value, logfile=self.logfile2, show_cmd=True, env=mock.ANY
|
|
|
|
),
|
2018-06-22 06:58:54 +00:00
|
|
|
],
|
|
|
|
)
|
2018-10-12 12:50:46 +00:00
|
|
|
self.assertEqual(
|
|
|
|
wc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(self.config1, [], ["foo", "pkg-devel"]),
|
2019-02-27 13:30:01 +00:00
|
|
|
mock.call(self.config2, [], ["foo.i686"]),
|
2018-10-12 12:50:46 +00:00
|
|
|
],
|
|
|
|
)
|
2018-06-22 06:58:54 +00:00
|
|
|
self.assertEqual(
|
|
|
|
gc.call_args_list,
|
|
|
|
[
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config1,
|
2018-06-22 06:58:54 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-06-22 06:58:54 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=[],
|
2018-06-22 06:58:54 +00:00
|
|
|
),
|
|
|
|
mock.call(
|
2018-10-12 12:50:46 +00:00
|
|
|
self.config2,
|
2018-06-22 06:58:54 +00:00
|
|
|
"x86_64",
|
2019-08-01 09:19:51 +00:00
|
|
|
["/path/for/p1"],
|
2018-06-22 06:58:54 +00:00
|
|
|
[],
|
|
|
|
platform=None,
|
2018-10-16 10:29:00 +00:00
|
|
|
filter_packages=[],
|
2018-06-22 06:58:54 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class TestExpandPackages(helpers.PungiTestCase):
|
|
|
|
def _mk_packages(self, src=None, debug_arch=None):
|
|
|
|
pkg = MockPkg(
|
|
|
|
name="pkg",
|
|
|
|
version="1",
|
|
|
|
release="2",
|
|
|
|
arch="x86_64",
|
|
|
|
epoch=3,
|
|
|
|
sourcerpm="pkg-1-2.src",
|
|
|
|
file_path="/tmp/pkg.rpm",
|
|
|
|
)
|
|
|
|
nevra_to_pkg = {"pkg-3:1-2.x86_64": pkg}
|
|
|
|
if src or debug_arch:
|
|
|
|
nevra_to_pkg["pkg-3:1-2.src"] = pkg._replace(
|
2019-02-08 09:10:41 +00:00
|
|
|
name="pkg", arch="src", file_path="/tmp/pkg.src.rpm"
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
if debug_arch:
|
|
|
|
nevra_to_pkg["pkg-debuginfo-3:1-2.%s" % debug_arch] = pkg._replace(
|
2019-02-08 09:10:41 +00:00
|
|
|
name="pkg-debuginfo",
|
|
|
|
arch=debug_arch,
|
|
|
|
file_path="/tmp/pkg-debuginfo.%s.rpm" % debug_arch
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
return nevra_to_pkg
|
|
|
|
|
|
|
|
def test_single_package(self):
|
|
|
|
nevra_to_pkg = self._mk_packages()
|
|
|
|
|
|
|
|
res = hybrid.expand_packages(
|
2019-07-03 11:53:26 +00:00
|
|
|
nevra_to_pkg, [], [("pkg-3:1-2", "x86_64", [])], []
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
res,
|
|
|
|
{
|
|
|
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
|
|
|
"srpm": [],
|
|
|
|
"debuginfo": [],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2019-02-27 13:30:01 +00:00
|
|
|
def test_include_src(self):
|
|
|
|
nevra_to_pkg = self._mk_packages(src=True)
|
2018-06-22 06:58:54 +00:00
|
|
|
|
|
|
|
res = hybrid.expand_packages(
|
2019-07-03 11:53:26 +00:00
|
|
|
nevra_to_pkg, [], [("pkg-3:1-2", "x86_64", [])], []
|
2019-02-08 09:10:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
res,
|
|
|
|
{
|
|
|
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
|
|
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
|
|
|
"debuginfo": [],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2019-02-27 13:30:01 +00:00
|
|
|
def test_filter_src(self):
|
|
|
|
nevra_to_pkg = self._mk_packages(src=True)
|
2019-02-08 09:10:41 +00:00
|
|
|
|
|
|
|
res = hybrid.expand_packages(
|
|
|
|
nevra_to_pkg,
|
|
|
|
[],
|
|
|
|
[("pkg-3:1-2", "x86_64", [])],
|
2019-02-27 13:30:01 +00:00
|
|
|
filter_packages=[("pkg", "src")],
|
2019-02-08 09:10:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
res,
|
|
|
|
{
|
|
|
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
2019-02-27 13:30:01 +00:00
|
|
|
"srpm": [],
|
2019-02-08 09:10:41 +00:00
|
|
|
"debuginfo": [],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2019-02-27 13:30:01 +00:00
|
|
|
def test_modular_include_src(self):
|
|
|
|
nevra_to_pkg = self._mk_packages(src=True)
|
2018-07-31 12:01:19 +00:00
|
|
|
|
|
|
|
res = hybrid.expand_packages(
|
2019-07-03 11:53:26 +00:00
|
|
|
nevra_to_pkg, [], [("pkg-3:1-2", "x86_64", ["modular"])], []
|
2018-07-31 12:01:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
res,
|
|
|
|
{
|
|
|
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
2019-02-08 09:10:41 +00:00
|
|
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
2018-07-31 12:01:19 +00:00
|
|
|
"debuginfo": [],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_modular_debug_in_correct_place(self):
|
|
|
|
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
|
|
|
|
|
|
|
res = hybrid.expand_packages(
|
2019-07-03 11:53:26 +00:00
|
|
|
nevra_to_pkg, [], [("pkg-debuginfo-3:1-2", "x86_64", ["modular"])], []
|
2018-07-31 12:01:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
res,
|
|
|
|
{
|
|
|
|
"rpm": [],
|
2019-02-08 09:10:41 +00:00
|
|
|
"srpm": [{"path": "/tmp/pkg.src.rpm", "flags": []}],
|
|
|
|
"debuginfo": [{"path": "/tmp/pkg-debuginfo.x86_64.rpm", "flags": []}],
|
2018-07-31 12:01:19 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2018-06-22 06:58:54 +00:00
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.cr")
|
2019-02-27 13:30:01 +00:00
|
|
|
def test_skip_lookaside_source(self, cr):
|
|
|
|
nevra_to_pkg = self._mk_packages(src=True)
|
2018-06-22 06:58:54 +00:00
|
|
|
lookasides = [mock.Mock()]
|
|
|
|
repo = {
|
|
|
|
"abc": NamedMock(
|
|
|
|
name="pkg",
|
|
|
|
arch="src",
|
|
|
|
location_base="file:///tmp/",
|
2019-02-08 09:10:41 +00:00
|
|
|
location_href="pkg.src.rpm",
|
2018-06-22 06:58:54 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
cr.Metadata.return_value.keys.return_value = repo.keys()
|
|
|
|
cr.Metadata.return_value.get.side_effect = lambda key: repo[key]
|
|
|
|
|
|
|
|
res = hybrid.expand_packages(
|
2019-07-03 11:53:26 +00:00
|
|
|
nevra_to_pkg, lookasides, [("pkg-3:1-2", "x86_64", [])], []
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(
|
|
|
|
res,
|
|
|
|
{
|
|
|
|
"rpm": [{"path": "/tmp/pkg.rpm", "flags": []}],
|
|
|
|
"srpm": [],
|
|
|
|
"debuginfo": [],
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch("pungi.phases.gather.methods.method_hybrid.cr")
|
|
|
|
def test_skip_lookaside_packages(self, cr):
|
|
|
|
nevra_to_pkg = self._mk_packages(debug_arch="x86_64")
|
|
|
|
lookasides = [mock.Mock()]
|
|
|
|
repo = {
|
|
|
|
"abc": NamedMock(
|
|
|
|
name="pkg",
|
|
|
|
arch="x86_64",
|
|
|
|
location_base="file:///tmp/",
|
|
|
|
location_href="pkg.rpm",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
cr.Metadata.return_value.keys.return_value = repo.keys()
|
|
|
|
cr.Metadata.return_value.get.side_effect = lambda key: repo[key]
|
|
|
|
|
|
|
|
res = hybrid.expand_packages(
|
2019-07-03 11:53:26 +00:00
|
|
|
nevra_to_pkg, lookasides, [("pkg-3:1-2", "x86_64", [])], []
|
2018-06-22 06:58:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
self.assertEqual(res, {"rpm": [], "srpm": [], "debuginfo": []})
|
2018-10-03 10:19:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestFilterModules(helpers.PungiTestCase):
|
|
|
|
def test_remove_one(self):
|
|
|
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
|
|
|
self.variant = self.compose.variants["Server"]
|
|
|
|
self.variant.arch_mmds["x86_64"] = {
|
|
|
|
"mod:1": MockModule("mod", platform="f29"),
|
|
|
|
"mod:2": MockModule("mod", platform="f30"),
|
|
|
|
}
|
|
|
|
|
|
|
|
hybrid.filter_modules(self.variant, "x86_64", ["mod:1"])
|
|
|
|
|
2019-10-04 12:45:03 +00:00
|
|
|
self.assertEqual(list(self.variant.arch_mmds["x86_64"].keys()), ["mod:1"])
|