2017-01-26 07:49:17 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
2019-10-04 12:45:03 +00:00
|
|
|
import six
|
2017-01-26 07:49:17 +00:00
|
|
|
|
2017-01-26 07:59:47 +00:00
|
|
|
from pungi.wrappers import repoclosure as rc
|
2017-01-26 07:49:17 +00:00
|
|
|
|
2018-10-22 12:14:53 +00:00
|
|
|
from . import helpers
|
|
|
|
|
2017-01-26 07:49:17 +00:00
|
|
|
|
2018-10-22 12:14:53 +00:00
|
|
|
class RepoclosureWrapperTestCase(helpers.BaseTestCase):
|
2017-01-26 07:49:17 +00:00
|
|
|
def test_minimal_command(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
|
|
|
rc.get_repoclosure_cmd(), ["/usr/bin/repoclosure", "--tempcache"]
|
|
|
|
)
|
2017-01-26 07:49:17 +00:00
|
|
|
|
2017-01-26 08:19:12 +00:00
|
|
|
def test_minimal_dnf_command(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(rc.get_repoclosure_cmd(backend="dnf"), ["dnf", "repoclosure"])
|
2017-01-26 08:19:12 +00:00
|
|
|
|
|
|
|
def test_unknown_backend(self):
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2020-01-22 10:02:22 +00:00
|
|
|
rc.get_repoclosure_cmd(backend="rpm")
|
2017-01-26 08:19:12 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(str(ctx.exception), "Unknown repoclosure backend: rpm")
|
2017-01-26 08:19:12 +00:00
|
|
|
|
2017-01-26 07:49:17 +00:00
|
|
|
def test_multiple_arches(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(
|
2021-11-02 07:49:04 +00:00
|
|
|
rc.get_repoclosure_cmd(arch=["x86_64", "i686", "noarch"]),
|
|
|
|
[
|
|
|
|
"/usr/bin/repoclosure",
|
|
|
|
"--tempcache",
|
|
|
|
"--arch=x86_64",
|
|
|
|
"--arch=i686",
|
|
|
|
"--arch=noarch",
|
|
|
|
],
|
2020-01-22 10:02:22 +00:00
|
|
|
)
|
2017-01-26 07:49:17 +00:00
|
|
|
|
|
|
|
def test_full_command(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
repos = {"my-repo": "/mnt/koji/repo"}
|
|
|
|
lookaside = {"fedora": "http://kojipkgs.fp.o/repo"}
|
2017-01-26 07:49:17 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
cmd = rc.get_repoclosure_cmd(arch="x86_64", repos=repos, lookaside=lookaside)
|
|
|
|
self.assertEqual(cmd[0], "/usr/bin/repoclosure")
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2017-01-26 07:49:17 +00:00
|
|
|
cmd[1:],
|
2019-11-20 04:04:40 +00:00
|
|
|
[
|
2020-01-22 10:02:22 +00:00
|
|
|
"--tempcache",
|
|
|
|
"--arch=x86_64",
|
|
|
|
"--repofrompath=my-repo,file:///mnt/koji/repo",
|
|
|
|
"--repofrompath=fedora,http://kojipkgs.fp.o/repo",
|
|
|
|
"--repoid=my-repo",
|
|
|
|
"--lookaside=fedora",
|
|
|
|
],
|
2019-11-20 04:04:40 +00:00
|
|
|
)
|
2017-01-26 07:49:17 +00:00
|
|
|
|
2017-01-26 08:19:12 +00:00
|
|
|
def test_full_dnf_command(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
repos = {"my-repo": "/mnt/koji/repo"}
|
|
|
|
lookaside = {"fedora": "http://kojipkgs.fp.o/repo"}
|
2017-01-26 08:19:12 +00:00
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
cmd = rc.get_repoclosure_cmd(
|
|
|
|
backend="dnf", arch="x86_64", repos=repos, lookaside=lookaside
|
|
|
|
)
|
|
|
|
self.assertEqual(cmd[:2], ["dnf", "repoclosure"])
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2017-01-26 08:19:12 +00:00
|
|
|
cmd[2:],
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
"--arch=x86_64",
|
2021-11-02 07:49:04 +00:00
|
|
|
"--forcearch=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_dnf_command_with_multiple_arches(self):
|
|
|
|
repos = {"my-repo": "/mnt/koji/repo"}
|
|
|
|
lookaside = {"fedora": "http://kojipkgs.fp.o/repo"}
|
|
|
|
|
|
|
|
cmd = rc.get_repoclosure_cmd(
|
|
|
|
backend="dnf",
|
|
|
|
arch=["x86_64", "i686", "noarch"],
|
|
|
|
repos=repos,
|
|
|
|
lookaside=lookaside,
|
|
|
|
)
|
|
|
|
self.assertEqual(cmd[:2], ["dnf", "repoclosure"])
|
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
|
|
|
cmd[2:],
|
|
|
|
[
|
|
|
|
"--arch=x86_64",
|
|
|
|
"--arch=i686",
|
|
|
|
"--arch=noarch",
|
|
|
|
"--forcearch=x86_64",
|
2020-01-22 10:02:22 +00:00
|
|
|
"--repofrompath=my-repo,file:///mnt/koji/repo",
|
|
|
|
"--repofrompath=fedora,http://kojipkgs.fp.o/repo",
|
|
|
|
"--repo=my-repo",
|
|
|
|
"--check=my-repo",
|
|
|
|
"--repo=fedora",
|
|
|
|
],
|
|
|
|
)
|
2017-01-26 08:19:12 +00:00
|
|
|
|
2017-01-26 07:49:17 +00:00
|
|
|
def test_expand_repo(self):
|
|
|
|
repos = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"local": "/mnt/koji/repo",
|
|
|
|
"remote": "http://kojipkgs.fp.o/repo",
|
2017-01-26 07:49:17 +00:00
|
|
|
}
|
|
|
|
cmd = rc.get_repoclosure_cmd(repos=repos)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(cmd[0], "/usr/bin/repoclosure")
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2017-01-26 07:49:17 +00:00
|
|
|
cmd[1:],
|
2019-11-20 04:04:40 +00:00
|
|
|
[
|
2020-01-22 10:02:22 +00:00
|
|
|
"--tempcache",
|
|
|
|
"--repofrompath=local,file:///mnt/koji/repo",
|
|
|
|
"--repofrompath=remote,http://kojipkgs.fp.o/repo",
|
|
|
|
"--repoid=local",
|
|
|
|
"--repoid=remote",
|
|
|
|
],
|
2019-11-20 04:04:40 +00:00
|
|
|
)
|
2017-01-26 07:49:17 +00:00
|
|
|
|
|
|
|
def test_expand_lookaside(self):
|
|
|
|
repos = {
|
2020-01-22 10:02:22 +00:00
|
|
|
"local": "/mnt/koji/repo",
|
|
|
|
"remote": "http://kojipkgs.fp.o/repo",
|
2017-01-26 07:49:17 +00:00
|
|
|
}
|
|
|
|
cmd = rc.get_repoclosure_cmd(lookaside=repos)
|
2020-01-22 10:02:22 +00:00
|
|
|
self.assertEqual(cmd[0], "/usr/bin/repoclosure")
|
2019-10-04 12:45:03 +00:00
|
|
|
six.assertCountEqual(
|
|
|
|
self,
|
2017-01-26 07:49:17 +00:00
|
|
|
cmd[1:],
|
2019-11-20 04:04:40 +00:00
|
|
|
[
|
2020-01-22 10:02:22 +00:00
|
|
|
"--tempcache",
|
|
|
|
"--repofrompath=local,file:///mnt/koji/repo",
|
|
|
|
"--repofrompath=remote,http://kojipkgs.fp.o/repo",
|
|
|
|
"--lookaside=local",
|
|
|
|
"--lookaside=remote",
|
|
|
|
],
|
2019-11-20 04:04:40 +00:00
|
|
|
)
|
2018-10-22 12:14:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FusExtractorTestCase(helpers.PungiTestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(FusExtractorTestCase, self).setUp()
|
2019-12-02 09:06:25 +00:00
|
|
|
self.input1 = os.path.join(self.topdir, "in1")
|
|
|
|
self.input2 = os.path.join(self.topdir, "in2")
|
2018-10-22 12:14:53 +00:00
|
|
|
self.output = os.path.join(self.topdir, "out")
|
|
|
|
|
|
|
|
def test_no_match(self):
|
2019-12-02 09:06:25 +00:00
|
|
|
helpers.touch(self.input1, "fus-DEBUG: Installing foo\n")
|
|
|
|
rc.extract_from_fus_logs([self.input1], self.output)
|
2018-10-22 12:14:53 +00:00
|
|
|
self.assertFileContent(self.output, "")
|
|
|
|
|
|
|
|
def test_error(self):
|
|
|
|
helpers.touch(
|
2019-12-02 09:06:25 +00:00
|
|
|
self.input1,
|
2020-01-22 10:02:22 +00:00
|
|
|
"fus-DEBUG: Installing bar\nProblem 1/1\n - nothing provides foo\n",
|
2018-10-22 12:14:53 +00:00
|
|
|
)
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
2019-12-02 09:06:25 +00:00
|
|
|
rc.extract_from_fus_logs([self.input1], self.output)
|
2018-10-22 12:14:53 +00:00
|
|
|
|
|
|
|
self.assertIn(self.output, str(ctx.exception))
|
|
|
|
|
|
|
|
self.assertFileContent(self.output, "Problem 1/1\n - nothing provides foo\n")
|
2019-12-02 09:06:25 +00:00
|
|
|
|
|
|
|
def test_errors_in_multiple_files(self):
|
|
|
|
helpers.touch(
|
|
|
|
self.input1,
|
2020-01-22 10:02:22 +00:00
|
|
|
"fus-DEBUG: Installing bar\nProblem 1/1\n - nothing provides foo\n",
|
2019-12-02 09:06:25 +00:00
|
|
|
)
|
|
|
|
helpers.touch(
|
|
|
|
self.input2,
|
2020-01-22 10:02:22 +00:00
|
|
|
"fus-DEBUG: Installing baz\nProblem 1/1\n - nothing provides quux\n",
|
2019-12-02 09:06:25 +00:00
|
|
|
)
|
|
|
|
with self.assertRaises(RuntimeError) as ctx:
|
|
|
|
rc.extract_from_fus_logs([self.input1, self.input2], self.output)
|
|
|
|
|
|
|
|
self.assertIn(self.output, str(ctx.exception))
|
|
|
|
|
|
|
|
self.assertFileContent(
|
|
|
|
self.output,
|
2020-02-06 07:09:32 +00:00
|
|
|
"Problem 1/1\n - nothing provides foo\nProblem 1/1\n - nothing provides quux\n", # noqa: E501
|
2019-12-02 09:06:25 +00:00
|
|
|
)
|