1+ import fnmatch
12import platform
23import shutil
34
@@ -74,6 +75,96 @@ def test_combinations_ssh_transfer(
7475 """
7576 pathtable , project = ssh_setup
7677
78+ expected_transferred_paths = self .get_expected_transferred_paths (
79+ pathtable , sub_names , ses_names , datatype
80+ )
81+
82+ self .check_transfer_ssh (
83+ project , sub_names , ses_names , datatype , expected_transferred_paths
84+ )
85+
86+ def test_ssh_wildcards_1 (self , ssh_setup ):
87+ pathtable , project = ssh_setup
88+
89+ sub_names = ["@*@date@*@" ]
90+ ses_names = ["all_ses" ]
91+ datatype = ["funcimg" ]
92+
93+ pathtable = pathtable [
94+ pathtable ["parent_sub" ]
95+ .fillna ("" )
96+ .apply (lambda x : fnmatch .fnmatch (x , "*date*" ))
97+ ]
98+
99+ pathtable = pathtable [
100+ pathtable ["parent_datatype" ].apply (lambda x : x == "funcimg" )
101+ ]
102+
103+ expected_transferred_paths = sorted (pathtable ["path" ])
104+
105+ self .check_transfer_ssh (
106+ project , sub_names , ses_names , datatype , expected_transferred_paths
107+ )
108+
109+ def test_ssh_wildcards_2 (self , ssh_setup ):
110+ pathtable , project = ssh_setup
111+
112+ sub_names = ["all_sub" ]
113+ ses_names = ["ses-003@*@" ]
114+ datatype = ["all_non_datatype" ]
115+
116+ pathtable = pathtable [
117+ pathtable ["parent_ses" ]
118+ .fillna ("" )
119+ .apply (lambda x : fnmatch .fnmatch (x , "ses-003*" ))
120+ ]
121+
122+ pathtable = pathtable [
123+ pathtable ["parent_datatype" ].apply (lambda x : x is None )
124+ ]
125+
126+ expected_transferred_paths = sorted (pathtable ["path" ])
127+
128+ self .check_transfer_ssh (
129+ project , sub_names , ses_names , datatype , expected_transferred_paths
130+ )
131+
132+ def test_ssh_wildcards_3 (self , ssh_setup ):
133+ pathtable , project = ssh_setup
134+
135+ sub_names = ["sub-002@TO@003_@*@" ]
136+ ses_names = ["ses-001" ]
137+ datatype = ["all" ]
138+
139+ pathtable = pathtable [
140+ pathtable ["parent_sub" ]
141+ .fillna ("" )
142+ .apply (
143+ lambda x : fnmatch .fnmatch (x , "sub-002*" )
144+ or fnmatch .fnmatch (x , "sub-003*" )
145+ )
146+ ]
147+
148+ pathtable = pathtable [
149+ pathtable ["parent_ses" ]
150+ .fillna ("" )
151+ .apply (lambda x : fnmatch .fnmatch (x , "ses-001*" ))
152+ ]
153+
154+ expected_transferred_paths = sorted (pathtable ["path" ])
155+
156+ self .check_transfer_ssh (
157+ project , sub_names , ses_names , datatype , expected_transferred_paths
158+ )
159+
160+ def check_transfer_ssh (
161+ self ,
162+ project ,
163+ sub_names ,
164+ ses_names ,
165+ datatype ,
166+ expected_transferred_paths ,
167+ ):
77168 # Upload data from the setup local project to a temporary
78169 # central directory.
79170 true_central_path = project .cfg ["central_path" ]
@@ -88,10 +179,6 @@ def test_combinations_ssh_transfer(
88179 "rawdata" , sub_names , ses_names , datatype , init_log = False
89180 )
90181
91- expected_transferred_paths = self .get_expected_transferred_paths (
92- pathtable , sub_names , ses_names , datatype
93- )
94-
95182 # Search the paths that were transferred and tidy them up,
96183 # then check against the paths that were expected to be transferred.
97184 transferred_files = ssh_test_utils .recursive_search_central (project )
0 commit comments