Files
bearhub/tests/gems/arch/test_pacman.py
Sebastian Palencsar e95a23bc20 M3 namespace migration: complete Phase B, partial Phase D, docs and tests
- Native runtime under bearhub/ (api, commons, gems, view/util, view/core, view/qt)
- bauh/ compatibility re-export shims for legacy imports
- Phase D: canonical __version__/__app_name__ in bearhub/__init__.py; pyproject.toml
  and setup.py point at bearhub package
- Native gem loader at bearhub/view/core/gems.py
- Namespace compatibility tests (159 tests passing)
- Documentation: CHANGELOG [Unreleased], NAMESPACE_MIGRATION, ROADMAP, README,
  CONTRIBUTING, docs/qt6-migration.md, packaging/aur/README.md
2026-06-27 10:26:41 +02:00

99 lines
4.0 KiB
Python

import os
import warnings
from unittest import TestCase
from unittest.mock import patch, Mock
from bearhub.gems.arch import pacman
FILE_DIR = os.path.dirname(os.path.abspath(__file__))
class PacmanTest(TestCase):
@classmethod
def setUpClass(cls):
warnings.filterwarnings('ignore', category=DeprecationWarning)
def test_list_ignored_packages(self):
ignored = pacman.list_ignored_packages(FILE_DIR + '/resources/pacman_ign_pkgs.conf')
self.assertIsNotNone(ignored)
self.assertEqual(2, len(ignored))
self.assertIn('google-chrome', ignored)
self.assertIn('firefox', ignored)
def test_list_ignored_packages__no_ignored_packages(self):
ignored = pacman.list_ignored_packages(FILE_DIR + '/resources/pacman.conf')
self.assertIsNotNone(ignored)
self.assertEqual(0, len(ignored))
@patch("bearhub.gems.arch.pacman.run_cmd", return_value="""
Name : package-test
Version : 3.4.4-1
Description : Test
Depends On : embree freetype2 libglvnd
Optional Deps : lib32-vulkan-icd-loader: Vulkan support [installed]
Required By : None
""")
def test_map_optional_deps__no_remote_and_not_installed__only_one_installed_with_description(self, run_cmd: Mock):
res = pacman.map_optional_deps(('package-test',), remote=False, not_installed=True)
run_cmd.assert_called_once_with('pacman -Qi package-test')
self.assertEqual({'package-test': {}}, res)
@patch("bearhub.gems.arch.pacman.run_cmd", return_value="""
Name : package-test
Version : 3.4.4-1
Description : Test
Depends On : embree freetype2 libglvnd
Optional Deps : lib32-vulkan-icd-loader: Vulkan support
Required By : None
""")
def test_map_optional_deps__no_remote_and_not_installed__only_one_not_installed_with_description(self, run_cmd: Mock):
res = pacman.map_optional_deps(('package-test',), remote=False, not_installed=True)
run_cmd.assert_called_once_with('pacman -Qi package-test')
self.assertEqual({'package-test': {'lib32-vulkan-icd-loader': 'Vulkan support'}}, res)
@patch("bearhub.gems.arch.pacman.run_cmd", return_value="""
Name : package-test
Version : 3.4.4-1
Description : Test
Depends On : embree freetype2 libglvnd
Optional Deps : pipewire-alsa
Required By : None
""")
def test_map_optional_deps__no_remote_and_not_installed__only_one_not_installed_no_description(self, run_cmd: Mock):
res = pacman.map_optional_deps(('package-test',), remote=False, not_installed=True)
run_cmd.assert_called_once_with('pacman -Qi package-test')
self.assertEqual({'package-test': {'pipewire-alsa': ''}}, res)
@patch("bearhub.gems.arch.pacman.run_cmd", return_value="""
Name : package-test
Version : 3.4.4-1
Description : Test
Depends On : embree freetype2 libglvnd
Optional Deps : pipewire-alsa [installed]
Required By : None
""")
def test_map_optional_deps__no_remote_and_not_installed__only_one_installed_no_description(self, run_cmd: Mock):
res = pacman.map_optional_deps(('package-test',), remote=False, not_installed=True)
run_cmd.assert_called_once_with('pacman -Qi package-test')
self.assertEqual({'package-test': {}}, res)
@patch("bearhub.gems.arch.pacman.run_cmd", return_value="""
Name : package-test
Version : 3.4.4-1
Description : Test
Depends On : embree freetype2 libglvnd libtheora
Optional Deps : pipewire-alsa
pipewire-pulse [installed]
pipewire
lib32-vulkan-icd-loader: Vulkan support [installed]
Required By : None
""")
def test_map_optional_deps__no_remote_and_not_installed__several(self, run_cmd: Mock):
res = pacman.map_optional_deps(('package-test',), remote=False, not_installed=True)
run_cmd.assert_called_once_with('pacman -Qi package-test')
self.assertEqual({'package-test': {'pipewire-alsa': '', 'pipewire': ''}}, res)