From 3c426c61c19b3deb6dd7259650e4db09e509310b Mon Sep 17 00:00:00 2001 From: Enrico Bravi Date: Wed, 8 May 2024 11:13:07 +0200 Subject: [PATCH] [ENTRY][Packages] Add support for snap and flatpak packages count --- archey/entries/packages.py | 2 ++ archey/test/entries/test_archey_packages.py | 33 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/archey/entries/packages.py b/archey/entries/packages.py index eb55cbdb..72168c58 100644 --- a/archey/entries/packages.py +++ b/archey/entries/packages.py @@ -43,6 +43,8 @@ def get_homebrew_cellar_path() -> str: {"tool": "slackware", "cmd": ("ls", "-1", "/var/log/packages/")}, # SlackWare. {"tool": "yum", "cmd": ("yum", "list", "installed"), "skew": 2}, {"tool": "zypper", "cmd": ("zypper", "search", "-i"), "skew": 5}, + {"tool": "snap", "cmd": ("snap", "list", "--all"), "skew": 1}, + {"tool": "flatpak", "cmd": ("flatpak", "list"), "skew": 1}, ) diff --git a/archey/test/entries/test_archey_packages.py b/archey/test/entries/test_archey_packages.py index b9d08d38..56d93a45 100644 --- a/archey/test/entries/test_archey_packages.py +++ b/archey/test/entries/test_archey_packages.py @@ -272,6 +272,39 @@ def test_match_with_zypper(self, check_output_mock): self.assertEqual(Packages().value, '(zypper) 5') + @patch( + "archey.entries.packages.check_output", + return_value="""\ +Name Version Rev Tracking Publisher Notes +gnome-3-38-2004 0+git.efb213a 143 latest/stable/… canonical✓ - +gnome-42-2204 0+git.510a601 176 latest/stable canonical✓ - +gtk-common-themes 0.1-81-g442e511 1535 latest/stable/… canonical✓ - +snap-store 41.3-66-gfe1e325 638 latest/stable/… canonical✓ - +""", + ) + def test_match_with_snap(self, check_output_mock): + """Simple test for the Snap packages manager""" + check_output_mock.side_effect = self._check_output_side_effect("snap") + + self.assertEqual(Packages().value, '(snap) 4') + + + @patch( + "archey.entries.packages.check_output", + return_value="""\ +Name Application ID Version Branch Origin Installation +Discord com.discordapp.Discord 0.0.35 stable flathub system +Xournal++ com.github.xournalpp.xournalpp 1.2.2 stable flathub system +draw.io com.jgraph.drawio.desktop 22.0.2 stable flathub system +Extension Manager com.mattjakeman.ExtensionManager 0.4.2 stable flathub system +""", + ) + def test_match_with_flatpak(self, check_output_mock): + """Simple test for the Flatpak packages manager""" + check_output_mock.side_effect = self._check_output_side_effect("flatpak") + + self.assertEqual(Packages().value, '(flatpak) 4') + @patch( "archey.entries.packages.PACKAGES_TOOLS", new=(