#NEWLINE# def test_service_policy_event_callback( self ) : #NEWLINE# #INDENT# service_policy_event = Mock ( ) #NEWLINE# service_policy_event . origin = 'policy_id' #NEWLINE# service_policy_event . service_name = 'UnitTestService' #NEWLINE# service_policy_event . op = 'test_op' #NEWLINE# container = Mock ( ) #NEWLINE# self . governance_controller . container = container #NEWLINE# container . proc_manager . is_local_service_process . return_value = False #NEWLINE# container . proc_manager . is_local_agent_process . return_value = False #NEWLINE# pdp = Mock ( ) #NEWLINE# self . governance_controller . policy_decision_point_manager = pdp #NEWLINE# self . governance_controller . service_policy_event_callback ( service_policy_event ) #NEWLINE# self . assertEqual ( pdp . called , False ) #NEWLINE# container . proc_manager . is_local_service_process . return_value = True #NEWLINE# policy_rules = 'policy_rules' #NEWLINE# pc = Mock ( ) #NEWLINE# self . governance_controller . policy_client = service_policy_event #NEWLINE# self . governance_controller . system_actor_user_header = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# pc . get_active_service_access_policy_rules . return_value = policy_rules #NEWLINE# local_process = Mock ( ) #NEWLINE# local_process . name = 'local_process' #NEWLINE# container . proc_manager . get_a_local_process . return_value = local_process #NEWLINE# self . governance_controller . register_process_operation_precondition ( local_process , 'test_op' , 'func1' ) #NEWLINE# op = Mock ( ) #NEWLINE# op . op = 'test_op_2' #NEWLINE# op . preconditions = [ 'func2' ] #NEWLINE# pc . get_active_process_operation_preconditions . return_value = [ op ] #NEWLINE# self . governance_controller . service_policy_event_callback ( service_policy_event ) #NEWLINE# self . assertEquals ( ( 'test_op' in self . governance_controller . get_process_operation_dict ( local_process . name ) ) , True ) #NEWLINE# self . assertEquals ( ( 'test_op_2' in self . governance_controller . get_process_operation_dict ( local_process . name ) ) , True ) #NEWLINE# pc . get_active_service_access_policy_rules . assert_called_with ( service_name = service_policy_event . service_name , org_name = self . governance_controller . container_org_name , headers = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# pdp . load_service_policy_rules . assert_called_with ( service_policy_event . service_name , policy_rules )