Skip to content

Commit a866a78

Browse files
committed
TST: Failing test to demonstrate SSH doesn't copy related files
1 parent a3a9ea5 commit a866a78

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
@@ -441,11 +441,16 @@ def test_jsonsink(tmpdir, inputs_attributes):
441441

442442
@pytest.mark.skipif(no_paramiko, reason="paramiko library is not available")
443443
def test_SSHDataGrabber(tmpdir):
444-
"""Test SSHDataGrabber by connecting to localhost and finding this test
445-
file.
444+
"""Test SSHDataGrabber by connecting to localhost and collecting some data.
446445
"""
447446
old_cwd = tmpdir.chdir()
448447

448+
source_dir = tmpdir.mkdir('source')
449+
source_hdr = source_dir.join('somedata.hdr')
450+
source_dat = source_dir.join('somedata.img')
451+
source_hdr.ensure() # create
452+
source_dat.ensure() # create
453+
449454
# ssh client that connects to localhost, current user, regardless of
450455
# ~/.ssh/config
451456
def _mock_get_ssh_client(self):
@@ -458,24 +463,24 @@ def _mock_get_ssh_client(self):
458463
MockSSHDataGrabber = copy.copy(nio.SSHDataGrabber)
459464
MockSSHDataGrabber._get_ssh_client = _mock_get_ssh_client
460465

461-
this_dir = os.path.dirname(__file__)
462-
this_file = os.path.basename(__file__)
463-
this_test = this_file[:-3] # without .py
464-
466+
# grabber to get files from source_dir matching test.hdr
465467
ssh_grabber = MockSSHDataGrabber(infields=['test'],
466468
outfields=['test_file'])
467-
# ssh_grabber.base_dir = str(tmpdir)
468-
ssh_grabber.inputs.base_directory = this_dir
469+
ssh_grabber.inputs.base_directory = str(source_dir)
469470
ssh_grabber.inputs.hostname = 'localhost'
470-
ssh_grabber.inputs.field_template = dict(test_file='%s.py')
471+
ssh_grabber.inputs.field_template = dict(test_file='%s.hdr')
471472
ssh_grabber.inputs.template = ''
472473
ssh_grabber.inputs.template_args = dict(test_file=[['test']])
473-
ssh_grabber.inputs.test = this_test
474+
ssh_grabber.inputs.test = 'somedata'
474475
ssh_grabber.inputs.sort_filelist = True
475476

476477
runtime = ssh_grabber.run()
477478

478-
# did we successfully get this file?
479-
assert runtime.outputs.test_file == str(tmpdir.join(this_file))
479+
# did we successfully get the header?
480+
assert runtime.outputs.test_file == str(tmpdir.join(source_hdr.basename))
481+
# did we successfully get the data?
482+
assert (tmpdir.join(source_hdr.basename) # header file
483+
.new(ext='.img') # data file
484+
.check(file=True, exists=True)) # exists?
480485

481486
old_cwd.chdir()

0 commit comments

Comments
 (0)