Skip to content

Commit e061922

Browse files
d-w-moorealanking
authored andcommitted
[#576] test admin mode in metadata.apply_atomic_operations
1 parent 519ce4e commit e061922

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

irods/test/meta_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,35 @@ def test_metadata_manipulations_with_admin_kw__364__365(self):
338338
if d: d.unlink(force=True)
339339
if user: user.remove()
340340

341+
def test_atomic_metadata_operations_with_admin_kw__issue_576(self):
342+
ses = data = user = None
343+
adm = self.sess
344+
345+
if adm.server_version <= (4,2,11):
346+
self.skipTest('ADMIN_KW not valid for Metadata API in iRODS 4.2.11 and previous')
347+
348+
try:
349+
# Create a rodsuser
350+
user = adm.users.create('bobby', 'rodsuser')
351+
user.modify('password', 'bpass')
352+
353+
# Log in as rodsuser and create a data object owned by that user.
354+
ses = iRODSSession(port = adm.port, zone = adm.zone, host = adm.host, user = user.name, password = 'bpass')
355+
home = helpers.home_collection(ses)
356+
data = ses.data_objects.create('{home}/issue_576'.format(**locals()))
357+
358+
# Do and test the results of the atomic set using the admin session, with the ADMIN_KW turned on.
359+
data_via_admin = adm.data_objects.get(data.path)
360+
avu_item = iRODSMeta('issue_576', 'dummy_value')
361+
data_via_admin.metadata(admin=True).apply_atomic_operations(AVUOperation(operation = "add", avu = avu_item))
362+
self.assertIn(avu_item, data_via_admin.metadata.items())
363+
finally:
364+
# Clean up objects after use.
365+
if ses:
366+
if ses.data_objects.exists(data.path):
367+
ses.data_objects.unlink(data.path, force = True)
368+
ses.cleanup()
369+
if user: user.remove()
341370

342371
def test_add_coll_meta(self):
343372
# add metadata to test collection

0 commit comments

Comments
 (0)