[PR #9842/c46575cf backport][stable-9] Simplify module_utils unit tests (#9843)

Simplify module_utils unit tests (#9842)

Simplify module_utils unit tests.

(cherry picked from commit c46575cf06)

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
patchback[bot] 2025-03-07 18:33:16 +01:00 committed by GitHub
parent 013fb9c006
commit ba7439e657
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 78 deletions

View file

@ -93,11 +93,12 @@ def test_get_fqdn_and_port(url, fqdn, port):
assert known_hosts.get_fqdn_and_port(url) == (fqdn, port)
@pytest.mark.parametrize('fqdn, port, add_host_key_cmd, stdin',
((URLS[k]['get_fqdn'], URLS[k]['port'], URLS[k]['add_host_key_cmd'], {})
for k in sorted(URLS) if URLS[k]['is_ssh_url']),
indirect=['stdin'])
def test_add_host_key(am, mocker, fqdn, port, add_host_key_cmd):
@pytest.mark.parametrize('fqdn, port, add_host_key_cmd',
((URLS[k]['get_fqdn'], URLS[k]['port'], URLS[k]['add_host_key_cmd'])
for k in sorted(URLS) if URLS[k]['is_ssh_url']))
def test_add_host_key(mocker, fqdn, port, add_host_key_cmd):
am = mocker.MagicMock()
get_bin_path = mocker.MagicMock()
get_bin_path.return_value = keyscan_cmd = "/custom/path/ssh-keyscan"
am.get_bin_path = get_bin_path