Skip to content

Commit 41fa351

Browse files
committed
avoid error when file already present
1 parent 296a3e3 commit 41fa351

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

qiita_client/tests/test_qiita_client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from qiita_client.qiita_client import (QiitaClient, _format_payload,
1919
ArtifactInfo)
2020
from qiita_client.testing import PluginTestCase, URL
21-
from qiita_client.exceptions import BadRequestError
21+
from qiita_client.exceptions import BadRequestError, ForbiddenError
2222

2323
CLIENT_ID = '19ndkO3oMKsoChjVVWluF7QkxHRfYhTKSFbAVt8IhK7gZgDaO4'
2424
BAD_CLIENT_ID = 'NOT_A_CLIENT_ID'
@@ -497,12 +497,17 @@ def test_delete_file_from_central(self):
497497
self.qclient._plugincoupling = protocol
498498

499499
# deposit a test file
500-
fp_test = join(cwd, 'deletme_%s.txt' % protocol)
500+
fp_test = join(cwd, 'deleteme_%s.txt' % protocol)
501501
makedirs(cwd, exist_ok=True)
502502
with open(fp_test, 'w') as f:
503503
f.write('This is a testfile content\n')
504504
self.clean_up_files.append(fp_test)
505-
self.qclient.push_file_to_central(fp_test)
505+
try:
506+
self.qclient.push_file_to_central(fp_test)
507+
except ForbiddenError as e:
508+
# previous test instances might not have cleaned this file
509+
# properly if ran with https protocol
510+
pass
506511

507512
# sanity check that test file has been deposited correctly
508513
fp_obs = self.qclient.fetch_file_from_central(fp_test)

0 commit comments

Comments
 (0)