repoclosure: add option to use dnf backend
This adds a new option repoclosure_backend that changes what tool is used for repoclosure. Checking build dependencies is currently not supported, as `dnf` does not have the corresponding option. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
95fc0fa4ab
commit
e3fe67be53
7 changed files with 109 additions and 21 deletions
|
|
@ -389,5 +389,17 @@ class TestRegexValidation(ConfigTestCase):
|
|||
[])
|
||||
|
||||
|
||||
class RepoclosureTestCase(ConfigTestCase):
|
||||
def test_invalid_backend(self):
|
||||
cfg = load_config(
|
||||
PKGSET_REPOS,
|
||||
repoclosure_backend='fnd', # Intentionally with a typo
|
||||
)
|
||||
|
||||
self.assertValidation(
|
||||
cfg,
|
||||
["Failed validation in repoclosure_backend: 'fnd' is not one of ['yum', 'dnf']"])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
|
|
@ -18,6 +18,16 @@ class RepoclosureWrapperTestCase(unittest.TestCase):
|
|||
self.assertEqual(rc.get_repoclosure_cmd(),
|
||||
['/usr/bin/repoclosure'])
|
||||
|
||||
def test_minimal_dnf_command(self):
|
||||
self.assertEqual(rc.get_repoclosure_cmd(backend='dnf'),
|
||||
['dnf', 'repoclosure'])
|
||||
|
||||
def test_unknown_backend(self):
|
||||
with self.assertRaises(RuntimeError) as ctx:
|
||||
rc.get_repoclosure_cmd(backend='rpm')
|
||||
|
||||
self.assertEqual(str(ctx.exception), 'Unknown repoclosure backend: rpm')
|
||||
|
||||
def test_multiple_arches(self):
|
||||
self.assertEqual(rc.get_repoclosure_cmd(arch=['x86_64', 'ppc64']),
|
||||
['/usr/bin/repoclosure', '--arch=x86_64', '--arch=ppc64'])
|
||||
|
|
@ -38,6 +48,22 @@ class RepoclosureWrapperTestCase(unittest.TestCase):
|
|||
'--repoid=my-repo',
|
||||
'--lookaside=fedora'])
|
||||
|
||||
def test_full_dnf_command(self):
|
||||
repos = {'my-repo': '/mnt/koji/repo'}
|
||||
lookaside = {'fedora': 'http://kojipkgs.fp.o/repo'}
|
||||
|
||||
cmd = rc.get_repoclosure_cmd(backend='dnf', arch='x86_64',
|
||||
repos=repos, lookaside=lookaside)
|
||||
self.assertEqual(cmd[:2], ['dnf', 'repoclosure'])
|
||||
self.assertItemsEqual(
|
||||
cmd[2:],
|
||||
['--arch=x86_64',
|
||||
'--repofrompath=my-repo,file:///mnt/koji/repo',
|
||||
'--repofrompath=fedora,http://kojipkgs.fp.o/repo',
|
||||
'--repo=my-repo',
|
||||
'--check=my-repo',
|
||||
'--repo=fedora'])
|
||||
|
||||
def test_expand_repo(self):
|
||||
repos = {
|
||||
'local': '/mnt/koji/repo',
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class TestRepoclosure(PungiTestCase):
|
|||
|
||||
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
|
||||
@mock.patch('pungi.phases.test.run')
|
||||
def test_calls_repoclosure(self, mock_run, mock_grc):
|
||||
def test_repoclosure_default_backend(self, mock_run, mock_grc):
|
||||
compose = DummyCompose(self.topdir, {})
|
||||
test_phase.run_repoclosure(compose)
|
||||
self.maxDiff = None
|
||||
|
|
@ -189,17 +189,43 @@ class TestRepoclosure(PungiTestCase):
|
|||
|
||||
self.assertItemsEqual(
|
||||
mock_grc.call_args_list,
|
||||
[mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
[mock.call(backend='yum', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Everything', 'amd64')),
|
||||
mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
mock.call(backend='yum', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Client', 'amd64')),
|
||||
mock.call(arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
mock.call(backend='yum', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Server', 'amd64')),
|
||||
mock.call(arch=['x86_64', 'noarch'], lookaside={},
|
||||
mock.call(backend='yum', arch=['x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Server', 'x86_64')),
|
||||
mock.call(arch=['x86_64', 'noarch'], lookaside={},
|
||||
mock.call(backend='yum', arch=['x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Everything', 'x86_64')),
|
||||
mock.call(arch={'x86_64', 'amd64', 'noarch'}, builddeps=True, repos=all_repos)])
|
||||
mock.call(backend='yum', arch={'x86_64', 'amd64', 'noarch'}, builddeps=True, repos=all_repos)])
|
||||
|
||||
@mock.patch('pungi.wrappers.repoclosure.get_repoclosure_cmd')
|
||||
@mock.patch('pungi.phases.test.run')
|
||||
def test_repoclosure_dnf_backend(self, mock_run, mock_grc):
|
||||
compose = DummyCompose(self.topdir, {'repoclosure_backend': 'dnf'})
|
||||
test_phase.run_repoclosure(compose)
|
||||
self.maxDiff = None
|
||||
all_repos = {}
|
||||
for variant in compose.variants.itervalues():
|
||||
for arch in variant.arches:
|
||||
all_repos.update(self._get_repo(variant.uid, arch))
|
||||
all_repos.update(self._get_repo(variant.uid, 'src', 'source/tree'))
|
||||
|
||||
self.assertItemsEqual(
|
||||
mock_grc.call_args_list,
|
||||
[mock.call(backend='dnf', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Everything', 'amd64')),
|
||||
mock.call(backend='dnf', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Client', 'amd64')),
|
||||
mock.call(backend='dnf', arch=['amd64', 'x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Server', 'amd64')),
|
||||
mock.call(backend='dnf', arch=['x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Server', 'x86_64')),
|
||||
mock.call(backend='dnf', arch=['x86_64', 'noarch'], lookaside={},
|
||||
repos=self._get_repo('Everything', 'x86_64')),
|
||||
mock.call(backend='dnf', arch={'x86_64', 'amd64', 'noarch'}, builddeps=True, repos=all_repos)])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue