Blame SOURCES/0030-Expose-plugin-unload-method-to-API-RhBug-2047251.patch

c115a0
From aa724a639a641943ecf39038fd694abc2037e66d Mon Sep 17 00:00:00 2001
c115a0
From: Jan Kolarik <jkolarik@redhat.com>
c115a0
Date: Mon, 22 Aug 2022 10:38:30 +0200
c115a0
Subject: [PATCH] Expose plugin unload method to API (RhBug:2047251)
c115a0
c115a0
= changelog =
c115a0
type: bugfix
c115a0
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2047251
c115a0
---
c115a0
 dnf/base.py                | 5 +++++
c115a0
 dnf/plugin.py              | 1 +
c115a0
 doc/api_base.rst           | 4 ++++
c115a0
 tests/api/test_dnf_base.py | 7 +++++++
c115a0
 4 files changed, 17 insertions(+)
c115a0
c115a0
diff --git a/dnf/base.py b/dnf/base.py
c115a0
index e623d98e..4ddfae15 100644
c115a0
--- a/dnf/base.py
c115a0
+++ b/dnf/base.py
c115a0
@@ -316,6 +316,11 @@ class Base(object):
c115a0
         """Run plugins configure() method."""
c115a0
         self._plugins._run_config()
c115a0
 
c115a0
+    def unload_plugins(self):
c115a0
+        # :api
c115a0
+        """Run plugins unload() method."""
c115a0
+        self._plugins._unload()
c115a0
+
c115a0
     def update_cache(self, timer=False):
c115a0
         # :api
c115a0
 
c115a0
diff --git a/dnf/plugin.py b/dnf/plugin.py
c115a0
index 06066e79..87c1f08f 100644
c115a0
--- a/dnf/plugin.py
c115a0
+++ b/dnf/plugin.py
c115a0
@@ -164,6 +164,7 @@ class Plugins(object):
c115a0
         self._caller('transaction')
c115a0
 
c115a0
     def _unload(self):
c115a0
+        logger.debug(_('Plugins were unloaded'))
c115a0
         del sys.modules[DYNAMIC_PACKAGE]
c115a0
 
c115a0
     def unload_removed_plugins(self, transaction):
c115a0
diff --git a/doc/api_base.rst b/doc/api_base.rst
c115a0
index 03396b69..35cbeef5 100644
c115a0
--- a/doc/api_base.rst
c115a0
+++ b/doc/api_base.rst
c115a0
@@ -97,6 +97,10 @@
c115a0
 
c115a0
      Configure plugins by running their configure() method.
c115a0
 
c115a0
+  .. method:: unload_plugins()
c115a0
+
c115a0
+     Unload all plugins.
c115a0
+
c115a0
   .. method:: fill_sack([load_system_repo=True, load_available_repos=True])
c115a0
 
c115a0
     Setup the package sack. If `load_system_repo` is ``True``, load information about packages in the local RPMDB into the sack. Else no package is considered installed during dependency solving. If `load_available_repos` is ``True``, load information about packages from the available repositories into the sack.
c115a0
diff --git a/tests/api/test_dnf_base.py b/tests/api/test_dnf_base.py
c115a0
index 33598189..e84e272b 100644
c115a0
--- a/tests/api/test_dnf_base.py
c115a0
+++ b/tests/api/test_dnf_base.py
c115a0
@@ -95,6 +95,13 @@ class DnfBaseApiTest(TestCase):
c115a0
 
c115a0
         self.base.configure_plugins()
c115a0
 
c115a0
+    def test_unload_plugins(self):
c115a0
+        # Base.unload_plugins()
c115a0
+        self.assertHasAttr(self.base, "unload_plugins")
c115a0
+
c115a0
+        self.base.init_plugins()
c115a0
+        self.base.unload_plugins()
c115a0
+
c115a0
     def test_update_cache(self):
c115a0
         # Base.update_cache(self, timer=False)
c115a0
         self.assertHasAttr(self.base, "update_cache")
c115a0
-- 
c115a0
2.37.1
c115a0