From cc558493b734f0f6b75b5700419945f0980ead86 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Mar 17 2022 13:35:46 +0000 Subject: Use absolute path for mock results in `lint` And activate related unittest, that was disabled because of its name (prefix was missing). Signed-off-by: Ondrej Nosek --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 53e6e47..331c354 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2658,8 +2658,7 @@ class Commands(object): rpm_globs = set() srpm_base = "%s-%s-%s.src.rpm" % (self.repo_name, self.ver, self.rel) - mockdir = os.path.join( - "results_%s" % self.repo_name, self.ver, self.rel) + mockdir = self.mock_results_dir if os.path.exists(mockdir): log.info("Mockbuild results directory found. " "Linting mockbuild results.") diff --git a/tests/test_commands.py b/tests/test_commands.py index 2009c93..c6fdc5b 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1068,19 +1068,20 @@ class TestLint(CommandTestCase): @patch('pyrpkg.Commands._run_command') @patch('pyrpkg.Commands.load_rpmdefines', new=mock_load_rpmdefines) @patch('pyrpkg.Commands.rel', new_callable=PropertyMock) - def lint_mockbuild(self, rel, run, exists, glob): + def test_lint_mockbuild(self, rel, run, exists, glob): rel.return_value = '2.fc26' cmd = self.make_commands() - mockdir = os.path.join(cmd.path, 'results_docpkg/1.2.2/2.fc26') + mockdir = os.path.join(cmd.path, + 'results_%s/1.2/2.fc26' % os.path.basename(self.repo_path)) srpm_path = os.path.join(mockdir, 'docpkg-1.2-2.fc26.src.rpm') bin_path = os.path.join(mockdir, 'docpkg-1.2-2.fc26.x86_64.rpm') def _mock_exists(path): - return path in [mockdir] + return path in mockdir def _mock_glob(g): - return {mockdir: [srpm_path, bin_path]}[g] + return {os.path.join(mockdir, '*.rpm'): [srpm_path, bin_path]}[g] exists.side_effect = _mock_exists glob.side_effect = _mock_glob @@ -1094,7 +1095,7 @@ class TestLint(CommandTestCase): return_stdout=True, return_text=True), call(['rpmlint', - os.path.join(cmd.path, 'dockpkg.spec'), + os.path.join(cmd.path, 'docpkg.spec'), srpm_path, bin_path, ], shell=True)])