def test_make_on_event_docstring_not_controller(self):
     doc = InterfaceEventDispatcher._make_on_walkoff_event_docstring(WalkoffEvent.ActionStarted)
     self.assertIn('sender_uids', doc)
     self.assertIn('sender_ids', doc)
     self.assertIn('names', doc)
     self.assertIn('weak', doc)
     self.assertIn('def handler(data)', doc)
 def test_make_on_event_docstring_controller(self):
     doc = InterfaceEventDispatcher._make_on_walkoff_event_docstring(WalkoffEvent.SchedulerStart)
     self.assertIn('weak', doc)
     self.assertNotIn('sender_uids', doc)
     self.assertNotIn('sender_ids', doc)
     self.assertNotIn('names', doc)
     self.assertIn('def handler()', doc)
 def test_all_events_are_controller_single_non_controller(self):
     self.assertFalse(
         InterfaceEventDispatcher._all_events_are_controller(
             {WalkoffEvent.ActionStarted}))
 def test_singleton(self):
     self.assertEqual(id(dispatcher), id(InterfaceEventDispatcher()))
    def test_validate_handler_function_args_controller_too_many(self):
        def x(a):
            pass

        with self.assertRaises(InvalidEventHandler):
            InterfaceEventDispatcher._validate_handler_function_args(x, True)
    def test_validate_handler_function_args_controller_valid(self):
        def x():
            pass

        InterfaceEventDispatcher._validate_handler_function_args(x, True)
    def test_validate_handler_function_args_not_controller_too_few(self):
        def x():
            pass

        with self.assertRaises(InvalidEventHandler):
            InterfaceEventDispatcher._validate_handler_function_args(x, False)
 def test_all_events_are_controller_mixed_events(self):
     with self.assertRaises(ValueError):
         InterfaceEventDispatcher._all_events_are_controller(
             {WalkoffEvent.WorkflowShutdown, WalkoffEvent.SchedulerStart})
 def test_all_events_are_controller_multiple_non_controller(self):
     self.assertFalse(InterfaceEventDispatcher._all_events_are_controller({WalkoffEvent.ActionStarted,
                                                                           WalkoffEvent.ActionExecutionError}))
 def test_make_on_event_docstring_not_controller(self):
     doc = InterfaceEventDispatcher._make_on_walkoff_event_docstring(WalkoffEvent.ActionStarted)
     self.assertIn('sender_ids', doc)
     self.assertIn('names', doc)
     self.assertIn('weak', doc)
     self.assertIn('def handler(data)', doc)
 def test_make_on_event_docstring_controller(self):
     doc = InterfaceEventDispatcher._make_on_walkoff_event_docstring(WalkoffEvent.SchedulerStart)
     self.assertIn('weak', doc)
     self.assertNotIn('sender_ids', doc)
     self.assertNotIn('names', doc)
     self.assertIn('def handler()', doc)
 def test_all_events_are_controller_mixed_events(self):
     with self.assertRaises(ValueError):
         InterfaceEventDispatcher._all_events_are_controller({WalkoffEvent.WorkflowShutdown,
                                                              WalkoffEvent.SchedulerStart})
 def test_all_events_are_controller_multiple_controller(self):
     self.assertTrue(InterfaceEventDispatcher._all_events_are_controller({WalkoffEvent.SchedulerStart,
                                                                          WalkoffEvent.SchedulerJobExecuted}))
 def test_all_events_are_controller_single_controller(self):
     self.assertTrue(InterfaceEventDispatcher._all_events_are_controller({WalkoffEvent.SchedulerStart}))
 def test_all_events_are_controller_multiple_non_controller(self):
     self.assertFalse(
         InterfaceEventDispatcher._all_events_are_controller({
             WalkoffEvent.ActionStarted, WalkoffEvent.ActionExecutionError
         }))
 def test_all_events_are_controller_multiple_controller(self):
     self.assertTrue(
         InterfaceEventDispatcher._all_events_are_controller({
             WalkoffEvent.SchedulerStart, WalkoffEvent.SchedulerJobExecuted
         }))
 def test_all_events_are_controller_single_controller(self):
     self.assertTrue(
         InterfaceEventDispatcher._all_events_are_controller(
             {WalkoffEvent.SchedulerStart}))
 def test_all_events_are_controller_single_non_controller(self):
     self.assertFalse(InterfaceEventDispatcher._all_events_are_controller({WalkoffEvent.ActionStarted}))