def test_ansible_ssh_command(inventory, expected): with tempfile.NamedTemporaryFile() as f: f.write(inventory + b'\n') f.flush() backend = AnsibleRunner(f.name).get_host('host').backend cmd, cmd_args = backend._build_ssh_command('true') command = backend.quote(' '.join(cmd), *cmd_args) assert command == expected
def test_ssh_hostspec(hostspec, expected): backend = testinfra.get_host(hostspec).backend cmd, cmd_args = backend._build_ssh_command('true') command = backend.quote(' '.join(cmd), *cmd_args) assert command == expected