1 |
commit: 31c04f4b5b014a6a80ad4d1c2c8574106bab2c56 |
2 |
Author: David Palao <david.palao <AT> gmail <DOT> com> |
3 |
AuthorDate: Fri Sep 16 15:08:41 2022 +0000 |
4 |
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Sep 25 19:10:34 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=31c04f4b |
7 |
|
8 |
improvement(bintree)!: binarytree.populate has new default getbinpkg_refresh=False |
9 |
|
10 |
This, together with a previous commit, fixes Bug #864259: |
11 |
|
12 |
sys-apps/portage: fetches binhost's 'Packages' file multiple times |
13 |
|
14 |
Bug: https://bugs.gentoo.org/864259 |
15 |
Signed-off-by: David Palao <david.palao <AT> gmail.com> |
16 |
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> |
17 |
|
18 |
lib/portage/dbapi/bintree.py | 2 +- |
19 |
lib/portage/tests/dbapi/test_bintree.py | 17 +++++++++++++++++ |
20 |
lib/portage/tests/emerge/test_actions.py | 5 +++++ |
21 |
3 files changed, 23 insertions(+), 1 deletion(-) |
22 |
|
23 |
diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py |
24 |
index cea9378d5..c8bb2c88e 100644 |
25 |
--- a/lib/portage/dbapi/bintree.py |
26 |
+++ b/lib/portage/dbapi/bintree.py |
27 |
@@ -807,7 +807,7 @@ class binarytree: |
28 |
except PortageException: |
29 |
pass |
30 |
|
31 |
- def populate(self, getbinpkgs=False, getbinpkg_refresh=True, add_repos=()): |
32 |
+ def populate(self, getbinpkgs=False, getbinpkg_refresh=False, add_repos=()): |
33 |
""" |
34 |
Populates the binarytree with package metadata. |
35 |
|
36 |
|
37 |
diff --git a/lib/portage/tests/dbapi/test_bintree.py b/lib/portage/tests/dbapi/test_bintree.py |
38 |
index 881d8ff48..4b4982a54 100644 |
39 |
--- a/lib/portage/tests/dbapi/test_bintree.py |
40 |
+++ b/lib/portage/tests/dbapi/test_bintree.py |
41 |
@@ -136,3 +136,20 @@ class BinarytreeTestCase(TestCase): |
42 |
), |
43 |
noiselevel=-1, |
44 |
) |
45 |
+ |
46 |
+ @patch("portage.dbapi.bintree.BinRepoConfigLoader") |
47 |
+ @patch("portage.dbapi.bintree.binarytree._populate_remote") |
48 |
+ @patch("portage.dbapi.bintree.binarytree._populate_local") |
49 |
+ def test_default_getbinpkg_refresh_in_populate( |
50 |
+ self, ppopulate_local, ppopulate_remote, pBinRepoConfigLoader |
51 |
+ ): |
52 |
+ """Bug #864259 |
53 |
+ This test fixes the bug. It requires that |
54 |
+ ``_emerge.actions.run_action`` calls ``binarytree.populate`` |
55 |
+ explicitly with ``getbinpkg_refresh=True`` |
56 |
+ """ |
57 |
+ settings = MagicMock() |
58 |
+ settings.__getitem__.return_value = "/some/path" |
59 |
+ bt = binarytree(pkgdir="/tmp", settings=settings) |
60 |
+ bt.populate(getbinpkgs=True) |
61 |
+ ppopulate_remote.assert_called_once_with(getbinpkg_refresh=False) |
62 |
|
63 |
diff --git a/lib/portage/tests/emerge/test_actions.py b/lib/portage/tests/emerge/test_actions.py |
64 |
index 014d39dd9..ee59cef5e 100644 |
65 |
--- a/lib/portage/tests/emerge/test_actions.py |
66 |
+++ b/lib/portage/tests/emerge/test_actions.py |
67 |
@@ -30,6 +30,11 @@ class RunActionTestCase(TestCase): |
68 |
papply, |
69 |
padjust, |
70 |
profile_ckeck): |
71 |
+ """Ensure that ``binarytree.populate`` API is correctly used. |
72 |
+ The point of this test is to ensure that the ``populate`` method |
73 |
+ is called as expected: since it is the first time that ``populate`` |
74 |
+ is called, it must use ``getbinpkg_refresh=True``. |
75 |
+ """ |
76 |
config = MagicMock() |
77 |
config.action = None |
78 |
config.opts = {"--quiet": True, "--usepkg": True} |