commit:     00ce1c2e21575c6154ce22d0fcf676e2654c56b3
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 11 03:29:17 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 11 07:23:08 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=00ce1c2e

tests: test_bintree: add test for trust helper --pretend issue

Followup to 6ae45739e208b7a9d59e0b6056be72a5791aae04.

Bug: https://bugs.gentoo.org/915842
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/tests/dbapi/test_bintree.py | 45 +++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/lib/portage/tests/dbapi/test_bintree.py 
b/lib/portage/tests/dbapi/test_bintree.py
index 0aa411ad97..018f1cf9bd 100644
--- a/lib/portage/tests/dbapi/test_bintree.py
+++ b/lib/portage/tests/dbapi/test_bintree.py
@@ -3,6 +3,7 @@
 
 from unittest.mock import MagicMock, patch, call
 import os
+import tempfile
 
 from portage.tests import TestCase
 
@@ -164,3 +165,47 @@ class BinarytreeTestCase(TestCase):
         bt = binarytree(pkgdir=os.getenv("TMPDIR", "/tmp"), settings=settings)
         bt.populate(getbinpkgs=True)
         ppopulate_remote.assert_called_once_with(getbinpkg_refresh=False, 
pretend=False)
+
+    @patch("portage.dbapi.bintree.BinRepoConfigLoader")
+    @patch("portage.dbapi.bintree.binarytree._run_trust_helper")
+    def test_default_getbinpkg_refresh_in_populate_trusthelper(
+        self, run_trust_helper, pBinRepoConfigLoader
+    ):
+        """
+        Test for bug #915842.
+
+        Verify that we call the trust helper in non-pretend mode.
+        """
+        settings = MagicMock()
+        settings.features = ["binpkg-request-signature"]
+        settings.__getitem__.return_value = "/some/path"
+
+        d = tempfile.TemporaryDirectory()
+        try:
+            bt = binarytree(pkgdir=d.name, settings=settings)
+            bt.populate(getbinpkgs=True, pretend=False)
+            run_trust_helper.assert_called_once()
+        finally:
+            d.cleanup()
+
+    @patch("portage.dbapi.bintree.BinRepoConfigLoader")
+    @patch("portage.dbapi.bintree.binarytree._run_trust_helper")
+    def test_default_getbinpkg_refresh_in_populate_trusthelper_pretend(
+        self, run_trust_helper, pBinRepoConfigLoader
+    ):
+        """
+        Test for bug #915842.
+
+        Verify we do not call the trust helper in pretend mode.
+        """
+        settings = MagicMock()
+        settings.features = ["binpkg-request-signature"]
+        settings.__getitem__.return_value = "/some/path"
+
+        d = tempfile.TemporaryDirectory()
+        try:
+            bt = binarytree(pkgdir=d.name, settings=settings)
+            bt.populate(getbinpkgs=True, pretend=True)
+            run_trust_helper.assert_not_called()
+        finally:
+            d.cleanup()

Reply via email to