88
99from unittest import TestCase
1010from os import environ , sep
11- from os .path import join , relpath
11+ from os .path import join , isabs
1212from time import sleep
1313
1414from qiita_client import QiitaClient
@@ -101,7 +101,18 @@ def deposite_in_qiita_basedir(self, fps, update_fp_only=False):
101101 update_fp_only : bool
102102 Some tests operate on filepaths only - files do not actually need
103103 to exist. Thus, we don't need to tranfer a file.
104+
105+ Returns
106+ -------
107+ The potentially modified filepaths.
104108 """
109+ def _stripRoot (fp ):
110+ # chop off leading / for join to work properly when prepending
111+ # the BASE_DATA_DIR
112+ if isabs (fp ):
113+ return fp [len (sep ):]
114+ return fp
115+
105116 if self .qclient ._plugincoupling == 'filesystem' :
106117 return fps
107118
@@ -117,13 +128,13 @@ def deposite_in_qiita_basedir(self, fps, update_fp_only=False):
117128 if isinstance (fps , str ):
118129 if not update_fp_only :
119130 self .qclient .push_file_to_central (fps )
120- return join (base_data_dir , relpath (fps , sep ))
131+ return join (base_data_dir , _stripRoot (fps ))
121132 elif isinstance (fps , list ):
122133 for fp in fps :
123134 if not update_fp_only :
124135 self .qclient .push_file_to_central (fp )
125- return [join (base_data_dir , relpath (fp , sep )) for fp in fps ]
136+ return [join (base_data_dir , _stripRoot (fp )) for fp in fps ]
126137 else :
127138 raise ValueError (
128- "_deposite_in_qiita_basedir is not implemented for type %s"
139+ "deposite_in_qiita_basedir is not implemented for type %s"
129140 % type (fps ))
0 commit comments