#NEWLINE# def test_sharing( self ) : #NEWLINE# #INDENT# def create_and_test( case_id , user , owner , should_have , should_not_have ) : #NEWLINE# #INDENT# case_block = self . get_create_block ( case_id = case_id , type = 'case' , user_id = user . user_id , owner_id = owner . get_id ) #NEWLINE# post_case_blocks ( [ case_block ] , { #NEWLINE# #INDENT# 'domain' : self . domain , #NEWLINE# #UNINDENT# } ) #NEWLINE# check_has_block ( case_block , should_have , should_not_have ) #NEWLINE# #UNINDENT# def update_and_test( case_id , owner = None , should_have = None , should_not_have = None ) : #NEWLINE# #INDENT# case_block = self . get_update_block ( case_id = case_id , update = { #NEWLINE# #INDENT# 'greeting' : 'Hello!' , #NEWLINE# #UNINDENT# } , owner_id = ( owner . get_id if owner else None ) ) #NEWLINE# post_case_blocks ( [ case_block ] , { #NEWLINE# #INDENT# 'domain' : self . domain , #NEWLINE# #UNINDENT# } ) #NEWLINE# check_has_block ( case_block , should_have , should_not_have , line_by_line = False ) #NEWLINE# #UNINDENT# def check_has_block( case_block , should_have , should_not_have , line_by_line = True ) : #NEWLINE# #INDENT# for user in should_have : #NEWLINE# #INDENT# check_user_has_case ( self , user . to_casexml_user ( ) , case_block , line_by_line = line_by_line ) #NEWLINE# #UNINDENT# for user in should_not_have : #NEWLINE# #INDENT# check_user_has_case ( self , user . to_casexml_user ( ) , case_block , should_have = False , line_by_line = line_by_line ) #NEWLINE# #UNINDENT# #UNINDENT# create_and_test ( case_id = 'case-a-1' , user = self . userA1 , owner = self . groupA , should_have = [ self . userA1 , self . userA2 , self . userX ] , should_not_have = [ self . userB1 , self . userB2 ] ) #NEWLINE# create_and_test ( case_id = 'case-b-1' , user = self . userB1 , owner = self . groupB , should_have = [ self . userB1 , self . userB2 , self . userX ] , should_not_have = [ self . userA1 , self . userA2 ] ) #NEWLINE# create_and_test ( case_id = 'case-a-2' , user = self . userX , owner = self . groupA , should_have = [ self . userA1 , self . userA2 , check_has_block . userX ] , should_not_have = [ self . userB1 , self . userB2 ] ) #NEWLINE# update_and_test ( case_id = 'case-a-1' , should_have = [ self . userA1 , self . userA2 , self . userX ] , should_not_have = [ self . userB1 , self . userB2 ] ) #NEWLINE# update_and_test ( case_id = 'case-a-1' , owner = self . groupB , should_have = [ self . userB1 , self . userB2 , self . userX ] , should_not_have = [ self . userA1 , self . userA2 ] )