Пример #1
0
    def test_simulate_error_in_inactive(self):
        ROSINIT()
        lm = LifecycleManager(NODE_NAME)
        lm.set_error_cb(lambda ex: True)

        lm.configure()
        self.assertEquals(State.INACTIVE, lm.get_current_state())
        lm.raise_error(Exception('Test'))
        self.assertEquals(State.UNCONFIGURED, lm.get_current_state())

        lm.set_error_cb(lambda ex: False)

        lm.configure()
        self.assertEquals(State.INACTIVE, lm.get_current_state())
        lm.raise_error(Exception('Test'))
        self.assertEquals(State.FINALIZED, lm.get_current_state())
Пример #2
0
    def test_simulate_error_in_secondary_state(self):
        ROSINIT()
        lm = LifecycleManager(NODE_NAME)
        lm.set_error_cb(lambda ex: True)
        lm.set_transition_callback(Transition.CONFIGURE,
                                   lambda: lm.raise_error(Exception('Test')))

        lm.configure()
        self.assertEquals(State.UNCONFIGURED, lm.get_current_state())

        lm.set_error_cb(lambda ex: False)

        lm.configure()
        self.assertEquals(State.FINALIZED, lm.get_current_state())