@@ -622,11 +622,16 @@ def test_bids_infields_outfields(tmpdir):
622
622
623
623
@pytest .mark .skipif (no_paramiko , reason = "paramiko library is not available" )
624
624
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.
627
626
"""
628
627
old_cwd = tmpdir .chdir ()
629
628
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
+
630
635
# ssh client that connects to localhost, current user, regardless of
631
636
# ~/.ssh/config
632
637
def _mock_get_ssh_client (self ):
@@ -639,24 +644,24 @@ def _mock_get_ssh_client(self):
639
644
MockSSHDataGrabber = copy .copy (nio .SSHDataGrabber )
640
645
MockSSHDataGrabber ._get_ssh_client = _mock_get_ssh_client
641
646
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
646
648
ssh_grabber = MockSSHDataGrabber (infields = ['test' ],
647
649
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 )
650
651
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 ' )
652
653
ssh_grabber .inputs .template = ''
653
654
ssh_grabber .inputs .template_args = dict (test_file = [['test' ]])
654
- ssh_grabber .inputs .test = this_test
655
+ ssh_grabber .inputs .test = 'somedata'
655
656
ssh_grabber .inputs .sort_filelist = True
656
657
657
658
runtime = ssh_grabber .run ()
658
659
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?
661
666
662
667
old_cwd .chdir ()
0 commit comments