code: def test_ssh_get_connection():
      manager = SSHManager()
      if _ssh_manager_is_multiplex:
          assert (
              manager._socket_dir is None
          ), "Should be unset upon initialization. Got %s" % str(
              manager._socket_dir
          )
      c1 = manager.get_connection("ssh://datalad-test")
  
      if _ssh_manager_is_multiplex:
          assert (
              manager._socket_dir
          ), "Should be set after interactions with the manager"
          assert_is_instance(c1, MultiplexSSHConnection)
          # subsequent call returns the very same instance:
          ok_(manager.get_connection("ssh://datalad-test") is c1)
      else:
          assert_is_instance(c1, NoMultiplexSSHConnection)
  
      # fail on malformed URls (meaning: our fancy URL parser can't correctly
      # deal with them):
      # assert_raises(ValueError, manager.get_connection, 'localhost')
      # we now allow those simple specifications of host to get_connection
      c2 = manager.get_connection("datalad-test")
      assert_is_instance(c2, SSHConnection)
  
      # but should fail if it looks like something else
      assert_raises(ValueError, manager.get_connection, "datalad-test/")
      assert_raises(ValueError, manager.get_connection, ":datalad-test")
  
      # we can do what urlparse cannot
      # assert_raises(ValueError, manager.get_connection, 'someone@localhost')
      # next one is considered a proper url by urlparse (netloc:'',
      # path='/localhost), but eventually gets turned into SSHRI(hostname='ssh',
      # path='/localhost') -- which is fair IMHO -> invalid test
      # assert_raises(ValueError, manager.get_connection, 'ssh:/localhost')
  
      manager.close()
  
file_path: datalad/datalad/support/tests/test_sshconnector.py
imports: import logging
  import os.path
  from os.path import exists, getmtime, isdir
  from os.path import join
  from datalad.tests.utils_pytest import SkipTest, assert_false, assert_in, assert_is_instance, assert_raises, eq_, get_most_obscure_supported_name, get_ssh_port, ok_, patch_config, skip_if_on_windows, skip_nomultiplex_ssh, skip_ssh, swallow_logs, with_tempfile, with_tree
  from datalad.utils import Path
  from ..sshconnector import MultiplexSSHConnection, MultiplexSSHManager, NoMultiplexSSHConnection, SSHConnection, SSHManager, get_connection_hash, sh_quote
label_desc: Use image node_id 1 for calling a global function with example usage: test_ssh_get_connection() without return types