code: def test_ssh_copy(sourcedir=None, sourcefile1=None, sourcefile2=None):
      port = get_ssh_port("datalad-test")
      remote_url = "ssh://datalad-test:{}".format(port)
      manager = SSHManager()
      ssh = manager.get_connection(remote_url)
  
      # copy content of sourcefile3 to an obscurely named file in sourcedir
      obscure_file = get_most_obscure_supported_name()
      obscure_path = opj(sourcedir, obscure_file)
      with open(obscure_path, "w") as f:
          f.write("three")
  
      # copy first two temp files to remote_url:sourcedir
      sourcefiles = [sourcefile1, sourcefile2]
      ssh.put(sourcefiles, opj(remote_url, sourcedir))
      # copy obscure file to remote_url:sourcedir/'<obscure_file_name>.c opy'
      # we copy to a different name because the test setup maps local dir and
      # remote dir to the same directory on the test machine. That means the file
      # is copied onto itself. With ssh version 9 this leads to an empty file.
      # We perform copy instead of just writing the content to the destination
      # file,  because ww want to ensure that the source file is picked up by
      # 'ssh.put()'.
      ssh.put(
          [obscure_path],
          opj(remote_url, sourcedir, obscure_file + ".c opy"),
      )
  
      # docs promise that connection is auto-opened in case of multiplex
      if _ssh_manager_is_multiplex:
          ok_(ssh.is_open())
  
      # recursive copy tempdir to remote_url:targetdir
      targetdir = sourcedir + ".c opy"
      ssh.put(
          sourcedir,
          opj(remote_url, targetdir),
          recursive=True,
          preserve_attrs=True,
      )
  
      # check if sourcedir copied to remote_url:targetdir
      ok_(isdir(targetdir))
      # check if scp preserved source directory attributes
      # if source_mtime=1.12s, scp -p sets target_mtime = 1.0s, test that
      eq_(getmtime(targetdir), int(getmtime(sourcedir)) + 0.0)
  
      # check if targetfiles(and its content) exist in remote_url:targetdir,
      # this implies file(s) and recursive directory copying pass
      for targetfile, content in zip(
          sourcefiles + [obscure_file + ".c opy"],
          ["one", "two", "three"],
      ):
          targetpath = opj(targetdir, targetfile)
          ok_(exists(targetpath))
          with open(targetpath, "r") as fp:
              eq_(content, fp.read())
  
      # and now a quick smoke test for get
      # but simplify the most obscure filename slightly to not trip `scp` itself
      togetfile = Path(targetdir) / (
          obscure_file.replace("`", "") + "2"
      )
      togetfile.write_text(str("something"))
      ssh.get(opj(remote_url, str(togetfile)), sourcedir)
      ok_((Path(sourcedir) / togetfile.name).exists())
  
      ssh.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 5 for calling a global function with example usage: test_ssh_copy(sourcedir, sourcefile1, sourcefile2) without return types