def test_controller_none_msg(self): log = test_utils.create_capture_log() # test subject core = EventCore(log=log) self.assertIsNotNone(core) # start test subject the_spawn = spawn(core.run) sleep(.005) # give the spawn a chance to initialize self.assertFalse(core.is_stopped) # test controller shutdown controller = core.controller controller.signal_message({}) sleep(0.01) # allow for processing of the message self.assertFalse(core.is_stopped) # ensure that the core is shutdown core.kill() sleep(0.005) the_spawn.join(timeout=5) self.assertTrue(core.is_stopped) self.assertListEqual(['Empty command message delivered.'], log.capture_handle.read_messages())
def test_simple_event_core(self): # test subject core = EventCore() self.assertIsNotNone(core) # test initial state self.assertTrue(core._stopped) # text run state the_spawn = spawn(core.run) sleep(0.005) # give the spawn a chance to initialize self.assertFalse(core.is_stopped) # test shutdown state core.kill() the_spawn.join(timeout=5) self.assertTrue(core.is_stopped)
def test_event_core_restart(self): # test subject core = EventCore(command_port=9901) self.assertIsNotNone(core) # start and shutdown in prep for restart the_spawn = spawn(core.run) sleep(0.005) core.kill() the_spawn.join(timeout=5) self.assertTrue(core.is_stopped) # restart the_spawn = spawn(core.run) sleep(0.005) self.assertFalse(core.is_stopped) core.kill() the_spawn.join(timeout=5) self.assertTrue(core.is_stopped)