summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorJames Falcon <james.falcon@canonical.com>2021-11-22 16:56:41 -0600
committerGitHub <noreply@github.com>2021-11-22 16:56:41 -0600
commit31daf6670aeeba1d452c70bc0d4d04139652be36 (patch)
treee892ab1389fdcd36c77ea985711b09e5d113dcdb /cloudinit/config
parent1343584dc03c50c80eabb8199c4e7d0d6fb4bd56 (diff)
downloadvyos-cloud-init-31daf6670aeeba1d452c70bc0d4d04139652be36.tar.gz
vyos-cloud-init-31daf6670aeeba1d452c70bc0d4d04139652be36.zip
testing: monkeypatch system_info call in unit tests (SC-533) (#1117)
testing: monkeypatch system_info call in unit tests system_info can make calls that read or write from the filesystem, which should require special mocking. It is also decorated with 'lru_cache', which means test authors often don't realize they need to be mocking. Also, we don't actually want the results from the user's local machine, so monkeypatching it across all tests should be reasonable. Additionally, moved some of 'system_info` into a helper function to reduce the surface area of the monkeypatch, added tests for the new function (and fixed a bug as a result), and removed related mocks that should be no longer needed.
Diffstat (limited to 'cloudinit/config')
-rw-r--r--cloudinit/config/tests/test_set_passwords.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/cloudinit/config/tests/test_set_passwords.py b/cloudinit/config/tests/test_set_passwords.py
index 79118a12..2a27f72f 100644
--- a/cloudinit/config/tests/test_set_passwords.py
+++ b/cloudinit/config/tests/test_set_passwords.py
@@ -121,13 +121,11 @@ class TestSetPasswordsHandle(CiTestCase):
m_subp.call_args_list)
@mock.patch(MODPATH + "util.multi_log")
- @mock.patch(MODPATH + "util.is_BSD")
@mock.patch(MODPATH + "subp.subp")
def test_handle_on_chpasswd_list_creates_random_passwords(
- self, m_subp, m_is_bsd, m_multi_log
+ self, m_subp, m_multi_log
):
"""handle parses command set random passwords."""
- m_is_bsd.return_value = False
cloud = self.tmp_cloud(distro='ubuntu')
valid_random_pwds = [
'root:R',