Skip to content

Commit a1b9905

Browse files
committed
TST: Failing test to demonstrate SSH doesn't copy related files
1 parent 8cdb260 commit a1b9905

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

449449
@pytest.mark.skipif(no_paramiko, reason="paramiko library is not available")
450450
def test_SSHDataGrabber(tmpdir):
451-
"""Test SSHDataGrabber by connecting to localhost and finding this test
452-
file.
451+
"""Test SSHDataGrabber by connecting to localhost and collecting some data.
453452
"""
454453
old_cwd = tmpdir.chdir()
455454

455+
source_dir = tmpdir.mkdir('source')
456+
source_hdr = source_dir.join('somedata.hdr')
457+
source_dat = source_dir.join('somedata.img')
458+
source_hdr.ensure() # create
459+
source_dat.ensure() # create
460+
456461
# ssh client that connects to localhost, current user, regardless of
457462
# ~/.ssh/config
458463
def _mock_get_ssh_client(self):
@@ -465,24 +470,24 @@ def _mock_get_ssh_client(self):
465470
MockSSHDataGrabber = copy.copy(nio.SSHDataGrabber)
466471
MockSSHDataGrabber._get_ssh_client = _mock_get_ssh_client
467472

468-
this_dir = os.path.dirname(__file__)
469-
this_file = os.path.basename(__file__)
470-
this_test = this_file[:-3] # without .py
471-
473+
# grabber to get files from source_dir matching test.hdr
472474
ssh_grabber = MockSSHDataGrabber(infields=['test'],
473475
outfields=['test_file'])
474-
# ssh_grabber.base_dir = str(tmpdir)
475-
ssh_grabber.inputs.base_directory = this_dir
476+
ssh_grabber.inputs.base_directory = str(source_dir)
476477
ssh_grabber.inputs.hostname = 'localhost'
477-
ssh_grabber.inputs.field_template = dict(test_file='%s.py')
478+
ssh_grabber.inputs.field_template = dict(test_file='%s.hdr')
478479
ssh_grabber.inputs.template = ''
479480
ssh_grabber.inputs.template_args = dict(test_file=[['test']])
480-
ssh_grabber.inputs.test = this_test
481+
ssh_grabber.inputs.test = 'somedata'
481482
ssh_grabber.inputs.sort_filelist = True
482483

483484
runtime = ssh_grabber.run()
484485

485-
# did we successfully get this file?
486-
assert runtime.outputs.test_file == str(tmpdir.join(this_file))
486+
# did we successfully get the header?
487+
assert runtime.outputs.test_file == str(tmpdir.join(source_hdr.basename))
488+
# did we successfully get the data?
489+
assert (tmpdir.join(source_hdr.basename) # header file
490+
.new(ext='.img') # data file
491+
.check(file=True, exists=True)) # exists?
487492

488493
old_cwd.chdir()

0 commit comments

Comments
 (0)