aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Palao <david.palao@gmail.com>2022-09-16 17:08:41 +0200
committerMike Gilbert <floppym@gentoo.org>2022-09-25 15:10:34 -0400
commit31c04f4b5b014a6a80ad4d1c2c8574106bab2c56 (patch)
treec56502c1671e157b3caeff2626334debceeb5a77
parenttest(actions): requiring that run_action calls binarytree.populate correctly (diff)
downloadportage-31c04f4b5b014a6a80ad4d1c2c8574106bab2c56.tar.gz
portage-31c04f4b5b014a6a80ad4d1c2c8574106bab2c56.tar.bz2
portage-31c04f4b5b014a6a80ad4d1c2c8574106bab2c56.zip
improvement(bintree)!: binarytree.populate has new default getbinpkg_refresh=False
This, together with a previous commit, fixes Bug #864259: sys-apps/portage: fetches binhost's 'Packages' file multiple times Bug: https://bugs.gentoo.org/864259 Signed-off-by: David Palao <david.palao@gmail.com> Signed-off-by: Mike Gilbert <floppym@gentoo.org>
-rw-r--r--lib/portage/dbapi/bintree.py2
-rw-r--r--lib/portage/tests/dbapi/test_bintree.py17
-rw-r--r--lib/portage/tests/emerge/test_actions.py5
3 files changed, 23 insertions, 1 deletions
diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py
index cea9378d5..c8bb2c88e 100644
--- a/lib/portage/dbapi/bintree.py
+++ b/lib/portage/dbapi/bintree.py
@@ -807,7 +807,7 @@ class binarytree:
except PortageException:
pass
- def populate(self, getbinpkgs=False, getbinpkg_refresh=True, add_repos=()):
+ def populate(self, getbinpkgs=False, getbinpkg_refresh=False, add_repos=()):
"""
Populates the binarytree with package metadata.
diff --git a/lib/portage/tests/dbapi/test_bintree.py b/lib/portage/tests/dbapi/test_bintree.py
index 881d8ff48..4b4982a54 100644
--- a/lib/portage/tests/dbapi/test_bintree.py
+++ b/lib/portage/tests/dbapi/test_bintree.py
@@ -136,3 +136,20 @@ class BinarytreeTestCase(TestCase):
),
noiselevel=-1,
)
+
+ @patch("portage.dbapi.bintree.BinRepoConfigLoader")
+ @patch("portage.dbapi.bintree.binarytree._populate_remote")
+ @patch("portage.dbapi.bintree.binarytree._populate_local")
+ def test_default_getbinpkg_refresh_in_populate(
+ self, ppopulate_local, ppopulate_remote, pBinRepoConfigLoader
+ ):
+ """Bug #864259
+ This test fixes the bug. It requires that
+ ``_emerge.actions.run_action`` calls ``binarytree.populate``
+ explicitly with ``getbinpkg_refresh=True``
+ """
+ settings = MagicMock()
+ settings.__getitem__.return_value = "/some/path"
+ bt = binarytree(pkgdir="/tmp", settings=settings)
+ bt.populate(getbinpkgs=True)
+ ppopulate_remote.assert_called_once_with(getbinpkg_refresh=False)
diff --git a/lib/portage/tests/emerge/test_actions.py b/lib/portage/tests/emerge/test_actions.py
index 014d39dd9..ee59cef5e 100644
--- a/lib/portage/tests/emerge/test_actions.py
+++ b/lib/portage/tests/emerge/test_actions.py
@@ -30,6 +30,11 @@ class RunActionTestCase(TestCase):
papply,
padjust,
profile_ckeck):
+ """Ensure that ``binarytree.populate`` API is correctly used.
+ The point of this test is to ensure that the ``populate`` method
+ is called as expected: since it is the first time that ``populate``
+ is called, it must use ``getbinpkg_refresh=True``.
+ """
config = MagicMock()
config.action = None
config.opts = {"--quiet": True, "--usepkg": True}