Skip to content

Commit e48240c

Browse files
committed
test ADMIN_KW not sticky, ie option deep copies are working
1 parent 719820e commit e48240c

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

irods/test/meta_test.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,9 @@ def test_destickifying_of_admin_option__issue_833(self):
806806
user = adm.users.create("bobby", "rodsuser")
807807
user.modify("password", "bpass")
808808
sessions = []
809+
810+
import pdb;pdb.set_trace()
811+
809812
for _ in range(2):
810813
with iRODSSession(
811814
port=adm.port,
@@ -814,14 +817,31 @@ def test_destickifying_of_admin_option__issue_833(self):
814817
user=user.name,
815818
password="bpass",
816819
) as ses:
817-
# Create a data object owned by the rodsuser. Set AVUs in various ways and guarantee each attempt
818-
# has the desired effect.
820+
# Get a reference to a data object owned by the rodsuser, creating it if not already there.
819821
d = ses.data_objects.create("/{adm.zone}/home/{user.name}/testfile".format(**locals()))
820-
if sessions:
821-
d.metadata.set('a','b')
822-
else:
822+
823+
# d.metadata is a different MetadataManager instance (and d, a different session instance) on the
824+
# second iteration of the loop as compared to the first. Thus, admin flags should not carry over.
825+
if not sessions:
823826
d.metadata(admin=True)
827+
else:
828+
# Should not be applying ADMIN_KW because INSUFFICIENT_PRIVILEGE_LEVEL exception would result
829+
d.metadata.set('a','b')
824830
sessions.append(ses)
831+
832+
# Admin option should be false after the second loop iteration.
833+
self.assertFalse(d.metadata.admin)
834+
835+
get_call_keywords = lambda metacoll: metacoll._manager._updated_keywords((),)
836+
837+
# Applying admin=True should result in API flags containing ADMIN_KW among the lookup keys.
838+
self.assertIn(kw.ADMIN_KW, get_call_keywords(md_modified:=d.metadata(admin=True)))
839+
840+
# Admin option should be on in the object options bookkeeping.
841+
self.assertTrue(md_modified.admin)
842+
843+
# However, the unmodified source object should not reflect use of an ADMIN_KW.
844+
self.assertNotIn(kw.ADMIN_KW, get_call_keywords(d.metadata)) # keyword updates not reflected in copied obj.
825845
finally:
826846
if d:
827847
d.unlink(force=True)

0 commit comments

Comments
 (0)