Skip to content

Commit b8d2446

Browse files
committed
TST: Failing test to demonstrate SSH doesn't copy related files
1 parent 97c4ed5 commit b8d2446

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

nipype/interfaces/tests/test_io.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -622,11 +622,16 @@ def test_bids_infields_outfields(tmpdir):
622622

623623
@pytest.mark.skipif(no_paramiko, reason="paramiko library is not available")
624624
def test_SSHDataGrabber(tmpdir):
625-
"""Test SSHDataGrabber by connecting to localhost and finding this test
626-
file.
625+
"""Test SSHDataGrabber by connecting to localhost and collecting some data.
627626
"""
628627
old_cwd = tmpdir.chdir()
629628

629+
source_dir = tmpdir.mkdir('source')
630+
source_hdr = source_dir.join('somedata.hdr')
631+
source_dat = source_dir.join('somedata.img')
632+
source_hdr.ensure() # create
633+
source_dat.ensure() # create
634+
630635
# ssh client that connects to localhost, current user, regardless of
631636
# ~/.ssh/config
632637
def _mock_get_ssh_client(self):
@@ -639,24 +644,24 @@ def _mock_get_ssh_client(self):
639644
MockSSHDataGrabber = copy.copy(nio.SSHDataGrabber)
640645
MockSSHDataGrabber._get_ssh_client = _mock_get_ssh_client
641646

642-
this_dir = os.path.dirname(__file__)
643-
this_file = os.path.basename(__file__)
644-
this_test = this_file[:-3] # without .py
645-
647+
# grabber to get files from source_dir matching test.hdr
646648
ssh_grabber = MockSSHDataGrabber(infields=['test'],
647649
outfields=['test_file'])
648-
# ssh_grabber.base_dir = str(tmpdir)
649-
ssh_grabber.inputs.base_directory = this_dir
650+
ssh_grabber.inputs.base_directory = str(source_dir)
650651
ssh_grabber.inputs.hostname = 'localhost'
651-
ssh_grabber.inputs.field_template = dict(test_file='%s.py')
652+
ssh_grabber.inputs.field_template = dict(test_file='%s.hdr')
652653
ssh_grabber.inputs.template = ''
653654
ssh_grabber.inputs.template_args = dict(test_file=[['test']])
654-
ssh_grabber.inputs.test = this_test
655+
ssh_grabber.inputs.test = 'somedata'
655656
ssh_grabber.inputs.sort_filelist = True
656657

657658
runtime = ssh_grabber.run()
658659

659-
# did we successfully get this file?
660-
assert runtime.outputs.test_file == str(tmpdir.join(this_file))
660+
# did we successfully get the header?
661+
assert runtime.outputs.test_file == str(tmpdir.join(source_hdr.basename))
662+
# did we successfully get the data?
663+
assert (tmpdir.join(source_hdr.basename) # header file
664+
.new(ext='.img') # data file
665+
.check(file=True, exists=True)) # exists?
661666

662667
old_cwd.chdir()

0 commit comments

Comments
 (0)