Simplify module_utils unit tests (#9842)

Simplify module_utils unit tests.
This commit is contained in:
Felix Fontein 2025-03-07 18:25:24 +01:00 committed by GitHub
parent a1781d09dd
commit c46575cf06
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