class TestModeHandler(unittest.TestCase): def setUp(self): self.handler = ModeHandler(TEST_MODES, MockController()) def test_mode_handling(self): # init stopped self.assertFalse(self.handler.controller.started) # active modes for mode in TEST_MODES: msg = Mode(mode) self.handler._handle_mode_msg(msg) self.assertTrue(self.handler.controller.started) # inactive mode msg = Mode('_not_an_active_mode') self.handler._handle_mode_msg(msg) self.assertFalse(self.handler.controller.started) def test_shutdown(self): self.handler.controller.start() self.assertTrue(self.handler.controller.started) self.handler.shutdown() self.assertFalse(self.handler.controller.started)
def setUp(self): self.handler = ModeHandler(TEST_MODES, MockController())
#!/usr/bin/env python import rospy from appctl_support import ProcController from appctl_support import ModeHandler if __name__ == '__main__': rospy.init_node('spin_test_node', anonymous=True) modes = ['test_appctl'] cmd = ['/bin/sh', '-c', 'sleep 23023023'] proc_controller = ProcController(cmd) mode_handler = ModeHandler(modes, proc_controller) mode_handler.begin_handling_modes() rospy.spin() # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4