commit: 31c04f4b5b014a6a80ad4d1c2c8574106bab2c56 Author: David Palao <david.palao <AT> gmail <DOT> com> AuthorDate: Fri Sep 16 15:08:41 2022 +0000 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> CommitDate: Sun Sep 25 19:10:34 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=31c04f4b
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 <AT> gmail.com> Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> lib/portage/dbapi/bintree.py | 2 +- lib/portage/tests/dbapi/test_bintree.py | 17 +++++++++++++++++ lib/portage/tests/emerge/test_actions.py | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) 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}
