def test_event_status(self): system = ZeroOrderHold(period_sec=0.1, vector_size=1) # Existence check. EventStatus.Severity.kDidNothing EventStatus.Severity.kSucceeded EventStatus.Severity.kReachedTermination EventStatus.Severity.kFailed self.assertIsInstance(EventStatus.DidNothing(), EventStatus) self.assertIsInstance(EventStatus.Succeeded(), EventStatus) status = EventStatus.ReachedTermination(system=system, message="done") # Check API. self.assertIsInstance(status, EventStatus) self.assertEqual( status.severity(), EventStatus.Severity.kReachedTermination) self.assertIs(status.system(), system) self.assertEqual(status.message(), "done") self.assertIsInstance( status.KeepMoreSevere(candidate=status), EventStatus) status = EventStatus.Failed(system=system, message="failed") self.assertIsInstance(status, EventStatus)
def _on_forced_unrestricted(self, context, state): test.assertIsInstance(context, Context) test.assertIsInstance(state, State) test.assertFalse(self.called_forced_unrestricted) self.called_forced_unrestricted = True return EventStatus.Succeeded()
def _on_forced_discrete(self, context, discrete_state): test.assertIsInstance(context, Context) test.assertIsInstance(discrete_state, DiscreteValues) test.assertFalse(self.called_forced_discrete) self.called_forced_discrete = True return EventStatus.Succeeded()
def _on_forced_publish(self, context): test.assertIsInstance(context, Context) test.assertFalse(self.called_forced_publish) self.called_forced_publish = True return EventStatus.Succeeded()
def _on_per_step_unrestricted(self, context, state): test.assertIsInstance(context, Context) test.assertIsInstance(state, State) self.called_per_step_unrestricted = True return EventStatus.Succeeded()
def _on_per_step_publish(self, context): test.assertIsInstance(context, Context) self.called_per_step_publish = True return EventStatus.Succeeded()