From e6404603ceafe46562f3be979713646546cc83bc Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Wed, 20 Mar 2024 16:20:26 -0400 Subject: [PATCH 1/2] Add missing mock, to prevent bleed through to test system --- tests/unittests/config/test_apt_key.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unittests/config/test_apt_key.py b/tests/unittests/config/test_apt_key.py index 4c6d613f3ee..2ae6b57b175 100644 --- a/tests/unittests/config/test_apt_key.py +++ b/tests/unittests/config/test_apt_key.py @@ -138,7 +138,9 @@ def test_apt_key_list_fail_no_keys_file(self, m_listdir, m_gpg, *args): "list", m_gpg ) - def test_apt_key_list_fail_bad_key_file(self, m_gpg): + @mock.patch.object(cc_apt_configure.os, "listdir", return_value=()) + @mock.patch.object(cc_apt_configure.os.path, "isfile", return_value=False) + def test_apt_key_list_fail_bad_key_file(self, m_listdir, m_gpg): """Ensure bad gpg key doesn't throw exeption.""" m_gpg.list_keys = mock.Mock(side_effect=subp.ProcessExecutionError) assert not cc_apt_configure.apt_key("list", m_gpg) From e958bdec5b142005b336646ff0744243f753c096 Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Thu, 21 Mar 2024 15:39:31 -0400 Subject: [PATCH 2/2] Fix mock pass through --- tests/unittests/config/test_apt_key.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unittests/config/test_apt_key.py b/tests/unittests/config/test_apt_key.py index 2ae6b57b175..6325bca5147 100644 --- a/tests/unittests/config/test_apt_key.py +++ b/tests/unittests/config/test_apt_key.py @@ -123,7 +123,7 @@ def test_apt_key_list_success_machine(self, m_gpg): @mock.patch.object(cc_apt_configure.os, "listdir", return_value=()) @mock.patch.object(cc_apt_configure.os.path, "isfile", return_value=False) - def test_apt_key_list_fail_no_keys(self, m_listdir, m_gpg): + def test_apt_key_list_fail_no_keys(self, m_isfile, m_listdir, m_gpg): """Ensure falsy output for no keys""" keys = cc_apt_configure.apt_key("list", m_gpg) assert not keys @@ -140,7 +140,7 @@ def test_apt_key_list_fail_no_keys_file(self, m_listdir, m_gpg, *args): @mock.patch.object(cc_apt_configure.os, "listdir", return_value=()) @mock.patch.object(cc_apt_configure.os.path, "isfile", return_value=False) - def test_apt_key_list_fail_bad_key_file(self, m_listdir, m_gpg): + def test_apt_key_list_fail_bad_key_file(self, m_isfile, m_listdir, m_gpg): """Ensure bad gpg key doesn't throw exeption.""" m_gpg.list_keys = mock.Mock(side_effect=subp.ProcessExecutionError) assert not cc_apt_configure.apt_key("list", m_gpg)