Skip to content

Commit ccd4be9

Browse files
committed
Fix teardown and test condition
1 parent d0f32a0 commit ccd4be9

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

datajoint/s3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,11 @@ def get_size(self, name):
7676
except minio.error.S3Error as e:
7777
if e.code == 'NoSuchKey':
7878
raise errors.MissingExternalFile
79-
raise e
79+
raise e
8080

8181
def remove_object(self, name):
8282
logger.debug('remove_object: {}:{}'.format(self.bucket, name))
8383
try:
8484
self.client.remove_object(self.bucket, str(name))
8585
except minio.error.MinioException:
8686
raise errors.DataJointError('Failed to delete %s from s3 storage' % name)
87-
except ValueError:
88-
raise errors.DataJointError('minIO ValueError something is wrong with the strings passed')

tests/test_s3.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,16 @@ def test_remove_object_exception():
122122
schema.external['share'].s3.client = minio_client
123123

124124
# This method returns a list of errors
125-
error_list = schema.external['share'].delete(delete_external_files=True, errors_as_string=False)
125+
error_list = schema.external['share'].delete(delete_external_files=True,
126+
errors_as_string=False)
126127

127128
# Teardown
129+
print(error_list[0][0])
128130
os.system('mc admin policy remove myminio test')
129131
os.system('mc admin user remove myminio jeffjeff')
130-
131-
# minio_admin.user_remove(access_key = 'jeffjeff')
132-
# minio_admin.policy_remove('test')
133132
schema.external['share'].s3.client = old_client
134-
135-
# Raise the error we want
136-
raise error_list[0][2]
133+
schema.external['share'].delete(delete_external_files=True)
134+
os.remove("/tmp/policy.json")
135+
# Raise the error we want if the error matches the expected uuid
136+
if str(error_list[0][0]) == '4c16e9e1-5b64-474e-4b56-ba22bb17faae':
137+
raise error_list[0][2]

0 commit comments

Comments
 (0)