Reuse arch pkgset repos

JIRA: COMPOSE-4217
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2020-03-25 17:02:25 +08:00
parent 63ec1adc22
commit 65251d983a
2 changed files with 107 additions and 2 deletions

View file

@ -114,3 +114,89 @@ class TestMaterializedPkgsetCreate(helpers.PungiTestCase):
os.path.join(self.topdir, "logs/x86_64/arch_repo_modulemd.foo.x86_64.log"),
)
cmd.return_value.add_module_stream.assert_called_once_with(mmd["x86_64"][0])
class TestCreateArchRepos(helpers.PungiTestCase):
def setUp(self):
super(TestCreateArchRepos, self).setUp()
self.compose = helpers.DummyCompose(self.topdir, {})
self.prefix = "/prefix"
self.paths = {}
self.pkgset = mock.Mock()
self.pkgset.reuse = None
self.pkgset.name = "foo"
@mock.patch("pungi.phases.pkgset.common._create_arch_repo")
def test_call_create_arch_repo(self, mock_create):
common.create_arch_repos(
self.compose, self.prefix, self.paths, self.pkgset, None
)
mock_create.assert_has_calls(
[
mock.call(
mock.ANY,
(self.compose, "amd64", self.prefix, self.paths, self.pkgset, None),
1,
),
mock.call(
mock.ANY,
(
self.compose,
"x86_64",
self.prefix,
self.paths,
self.pkgset,
None,
),
2,
),
]
)
@mock.patch("pungi.phases.pkgset.common._reuse_arch_repo")
def test_call_reuse_arch_repo(self, mock_reuse):
self.pkgset.reuse = "/path/to/old/global/repo"
common.create_arch_repos(
self.compose, self.prefix, self.paths, self.pkgset, None
)
mock_reuse.assert_has_calls(
[
mock.call(
mock.ANY,
(self.compose, "amd64", self.prefix, self.paths, self.pkgset, None),
1,
),
mock.call(
mock.ANY,
(
self.compose,
"x86_64",
self.prefix,
self.paths,
self.pkgset,
None,
),
2,
),
]
)
@mock.patch("pungi.phases.pkgset.common.copy_all")
def test_reuse_arch_repo(self, mock_copy_all):
self.pkgset.reuse = "/path/to/old/global/repo"
old_repo = "/path/to/old/repo"
self.compose.paths.old_compose_path = mock.Mock(return_value=old_repo)
common._reuse_arch_repo(
mock.Mock(),
(self.compose, "x86_64", self.prefix, self.paths, self.pkgset, None),
1,
)
mock_copy_all.assert_called_once_with(
old_repo, os.path.join(self.compose.topdir, "work/x86_64/repo/foo")
)
self.compose.log_info.assert_has_calls(
[
mock.call("[BEGIN] %s", "Copying repodata for reuse: %s" % old_repo),
mock.call("[DONE ] %s", "Copying repodata for reuse: %s" % old_repo),
]
)