From dc43e9e60993ff0dfaa6021c9bc582c792a56ba4 Mon Sep 17 00:00:00 2001 From: Sander Cornelissen <5145555+sanderc85@users.noreply.github.com> Date: Thu, 26 Oct 2023 09:44:03 +0200 Subject: [PATCH] Add test for fix when user does not exists on pip --- tests/unit/states/test_pip_state.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/unit/states/test_pip_state.py b/tests/unit/states/test_pip_state.py index e2a7c974520f..da83885176d0 100644 --- a/tests/unit/states/test_pip_state.py +++ b/tests/unit/states/test_pip_state.py @@ -379,6 +379,24 @@ def test_install_in_editable_mode(self): self.assertSaltTrueReturn({"test": ret}) self.assertInSaltComment("successfully installed", {"test": ret}) + def test_install_with_specified_user(self): + """ + Check that if `user` parameter is set and the user does not exists + it will fail with an error, see #65458 + """ + user_info = MagicMock(return_value={}) + pip_version = MagicMock(return_value="10.0.1") + with patch.dict( + pip_state.__salt__, + { + "user.info": user_info, + "pip.version": pip_version, + }, + ): + ret = pip_state.installed("mypkg", user='fred') + self.assertSaltFalseReturn({"test": ret}) + self.assertInSaltComment("User fred does not exist", {"test": ret}) + class PipStateUtilsTest(TestCase): def test_has_internal_exceptions_mod_function(self):