#NEWLINE# def test_get_actor_header( self ) : #NEWLINE# #INDENT# actor = IonObject ( RT . ActorIdentity , name = 'actor1' ) #NEWLINE# ( actor_id , _ ) = self . rr . create ( actor ) #NEWLINE# ion_org = IonObject ( RT . Org , name = 'ION' , org_governance_name = 'ION' ) #NEWLINE# ( ion_org_id , _ ) = self . rr . create ( ion_org ) #NEWLINE# ion_org . _id = ion_org_id #NEWLINE# manager_role = IonObject ( RT . UserRole , name = 'Org Manager' , governance_name = ORG_MANAGER_ROLE , description = 'Org Manager' ) #NEWLINE# manager_role_id = self . add_user_role ( ion_org , manager_role ) #NEWLINE# member_role = IonObject ( RT . UserRole , name = 'Org Member' , governance_name = ORG_MEMBER_ROLE , description = 'Org Member' ) #NEWLINE# actor_roles = find_roles_by_actor ( actor_id ) #NEWLINE# self . assertDictEqual ( actor_roles , { #NEWLINE# #INDENT# 'ION' : [ ORG_MEMBER_ROLE ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# actor_header = get_actor_header ( actor_id ) #NEWLINE# self . assertDictEqual ( actor_header , { #NEWLINE# #INDENT# 'ion-actor-id' : actor_id , #NEWLINE# 'ion-actor-roles' : { #NEWLINE# #INDENT# 'ION' : [ ORG_MEMBER_ROLE ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . rr . create_association ( actor_id , PRED . hasRole , manager_role_id ) #NEWLINE# actor_roles = find_roles_by_actor ( actor_id ) #NEWLINE# role_header = get_role_message_headers ( { #NEWLINE# #INDENT# 'ION' : [ manager_role , member_role ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertDictEqual ( actor_roles , role_header ) #NEWLINE# org2 = IonObject ( RT . Org , name = 'Org 2' , org_governance_name = 'Second_Org' ) #NEWLINE# ( org2_id , _ ) = self . rr . create ( org2 ) #NEWLINE# org2 . _id = org2_id #NEWLINE# member2_role = IonObject ( RT . UserRole , governance_name = ORG_MEMBER_ROLE , name = 'Org Member' , description = 'Org Member' ) #NEWLINE# member2_role_id = self . add_user_role ( org2 , member2_role ) #NEWLINE# operator2_role = IonObject ( RT . UserRole , governance_name = 'INSTRUMENT_OPERATOR' , name = 'Instrument Operator' , description = 'Instrument Operator' ) #NEWLINE# operator2_role_id = self . add_user_role ( org2 , operator2_role ) #NEWLINE# self . rr . create_association ( actor_id , PRED . hasRole , member2_role_id ) #NEWLINE# self . rr . create_association ( actor_id , PRED . hasRole , operator2_role_id ) #NEWLINE# actor_roles = find_roles_by_actor ( actor_id ) #NEWLINE# role_header = get_role_message_headers ( { #NEWLINE# #INDENT# 'ION' : [ manager_role , member_role ] , #NEWLINE# 'Second_Org' : [ operator2_role , member2_role ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . assertEqual ( len ( actor_roles ) , 2 ) #NEWLINE# self . assertEqual ( len ( role_header ) , 2 ) #NEWLINE# self . assertIn ( 'Second_Org' , actor_roles ) #NEWLINE# self . assertIn ( 'Second_Org' , role_header ) #NEWLINE# self . assertEqual ( len ( actor_roles [ 'Second_Org' ] ) , 2 ) #NEWLINE# self . assertEqual ( len ( role_header [ 'Second_Org' ] ) , 2 ) #NEWLINE# self . assertIn ( 'INSTRUMENT_OPERATOR' , actor_roles [ 'Second_Org' ] ) #NEWLINE# self . assertIn ( 'INSTRUMENT_OPERATOR' , role_header [ 'Second_Org' ] ) #NEWLINE# self . assertIn ( ORG_MEMBER_ROLE , actor_roles [ 'Second_Org' ] ) #NEWLINE# self . assertIn ( ORG_MEMBER_ROLE , role_header [ 'Second_Org' ] ) #NEWLINE# self . assertIn ( 'ION' , actor_roles ) #NEWLINE# self . assertIn ( 'ION' , role_header ) #NEWLINE# self . assertIn ( ORG_MANAGER_ROLE , actor_roles [ 'ION' ] ) #NEWLINE# self . assertIn ( ORG_MEMBER_ROLE , actor_roles [ 'ION' ] ) #NEWLINE# self . assertIn ( ORG_MANAGER_ROLE , role_header [ 'ION' ] ) #NEWLINE# self . assertIn ( ORG_MEMBER_ROLE , role_header [ 'ION' ] ) #NEWLINE# actor_header = get_actor_header ( actor_id ) #NEWLINE# self . assertEqual ( actor_header [ 'ion-actor-id' ] , actor_id ) #NEWLINE# self . assertEqual ( actor_header [ 'ion-actor-roles' ] , actor_roles ) #NEWLINE# org2 = self . rr . read ( org2_id ) #NEWLINE# org2 . name = 'Updated Org 2' #NEWLINE# ( org2_id , _ ) = self . rr . update ( org2 ) #NEWLINE# actor_roles = find_roles_by_actor ( actor_id ) #NEWLINE# self . assertEqual ( len ( actor_roles ) , 2 ) #NEWLINE# self . assertEqual ( len ( role_header ) , 2 ) #NEWLINE# self . assertIn ( 'Second_Org' , actor_roles ) #NEWLINE# self . assertIn ( 'Second_Org' , role_header ) #NEWLINE# self . assertEqual ( len ( actor_roles [ 'Second_Org' ] ) , 2 ) #NEWLINE# self . assertEqual ( len ( role_header [ 'Second_Org' ] ) , 2 ) #NEWLINE# self . assertIn ( 'INSTRUMENT_OPERATOR' , actor_roles [ 'Second_Org' ] ) #NEWLINE# self . assertIn ( 'INSTRUMENT_OPERATOR' , role_header [ 'Second_Org' ] ) #NEWLINE# self . assertIn ( ORG_MEMBER_ROLE , actor_roles [ 'Second_Org' ] ) #NEWLINE# self . assertIn ( ORG_MEMBER_ROLE , role_header [ 'Second_Org' ] ) #NEWLINE# self . assertIn ( 'ION' , actor_roles ) #NEWLINE# self . assertIn ( 'ION' , role_header ) #NEWLINE# self . assertIn ( ORG_MANAGER_ROLE , actor_roles [ 'ION' ] ) #NEWLINE# self . assertIn ( ORG_MEMBER_ROLE , actor_roles [ 'ION' ] ) #NEWLINE# self . assertIn ( ORG_MANAGER_ROLE , role_header [ 'ION' ] ) #NEWLINE# self . assertIn ( ORG_MEMBER_ROLE , role_header [ 'ION' ] ) #NEWLINE# actor_header = get_actor_header ( actor_id ) #NEWLINE# self . assertEqual ( actor_header [ 'ion-actor-id' ] , actor_id ) #NEWLINE# self . assertEqual ( actor_header [ 'ion-actor-roles' ] , actor_roles )