2121 iRODSMeta ,
2222)
2323from irods .models import Collection , CollectionMeta , DataObject , ModelBase , Resource
24+ from irods .path import iRODSPath
2425from irods .session import iRODSSession
2526from irods .test import helpers
2627
@@ -820,24 +821,22 @@ def test_binary_avu_fields__issue_707(self):
820821 def test_cascading_changes_of_metadata_manager_options__issue_709 (self ):
821822 d = None
822823
823- def get_option (metacoll , key ):
824- return metacoll ._manager ._opts [key ]
825824 try :
826825 d = self .sess .data_objects .create (f'{ self .coll .path } /issue_709_test_1' )
827826 m = d .metadata
828- self .assertEqual (get_option ( m , ' admin' ) , False )
827+ self .assertEqual (m . admin , False )
829828
830829 m2 = m (admin = True )
831- self .assertEqual (get_option ( m2 , ' timestamps' ) , False )
832- self .assertEqual (get_option ( m2 , ' admin' ) , True )
830+ self .assertEqual (m2 . timestamps , False )
831+ self .assertEqual (m2 . admin , True )
833832
834833 m3 = m2 (timestamps = True )
835- self .assertEqual (get_option ( m3 , ' timestamps' ) , True )
836- self .assertEqual (get_option ( m3 , ' admin' ) , True )
834+ self .assertEqual (m3 . timestamps , True )
835+ self .assertEqual (m3 . admin , True )
837836 self .assertEqual (m3 ._manager .get_api_keywords ().get (kw .ADMIN_KW ), "" )
838837
839838 m4 = m3 (admin = False )
840- self .assertEqual (get_option ( m4 , ' admin' ) , False )
839+ self .assertEqual (m4 . admin , False )
841840 self .assertEqual (m4 ._manager .get_api_keywords ().get (kw .ADMIN_KW ), None )
842841 finally :
843842 if d :
@@ -863,6 +862,15 @@ def test_reload_can_be_deactivated__issue_768(self):
863862 self .assertIn (item_1 , items_reloaded )
864863 self .assertIn (item_2 , items_reloaded )
865864
865+ def test_prevention_of_attribute_creation__issue_795 (self ):
866+ data_path = iRODSPath (self .coll_path , helpers .unique_name (datetime .datetime .now ())) # noqa: DTZ005
867+ data = self .sess .data_objects .create (data_path )
868+ with self .assertRaises (AttributeError ):
869+ # This should cause an error since "admin" is considered as a read-only attribute; whereas
870+ # data.metadata(admin = True) generates a cloned object but for the one change to "admin".
871+ data .metadata .admin = True
872+
873+
866874if __name__ == "__main__" :
867875 # let the tests find the parent irods lib
868876 sys .path .insert (0 , os .path .abspath ("../.." ))
0 commit comments