def test_maintenance_passthrough(self): """ Test the behavior of passthrough in maintenance mode. """ serial_mock = SerialMock([ sout("For passthrough"), sin(master_api.to_cli_mode().create_input(0)), sout("OK"), sin("error list\r\n"), sout("the list\n"), sin("exit\r\n"), sout("Passthrough again")]) comm = MasterCommunicator(serial_mock, init_master=False) comm.enable_passthrough() comm.start() def passthrough_thread(): """ Background thread that reads the passthrough data. """ self.assertEquals("For passthrough", comm.get_passthrough_data()) self.assertEquals("Passthrough again", comm.get_passthrough_data()) thread = threading.Thread(target=passthrough_thread) thread.start() comm.start_maintenance_mode() self.assertEquals("OK", comm.get_maintenance_data()) comm.send_maintenance_data("error list\r\n") self.assertEquals("the list\n", comm.get_maintenance_data()) comm.stop_maintenance_mode() thread.join()
def test_maintenance_passthrough(self): """ Test the behavior of passthrough in maintenance mode. """ serial_mock = SerialMock([ sout("For passthrough"), sin(master_api.to_cli_mode().create_input(0)), sout("OK"), sin("error list\r\n"), sout("the list\n"), sin("exit\r\n"), sout("Passthrough again") ]) comm = MasterCommunicator(serial_mock, init_master=False) comm.enable_passthrough() comm.start() def passthrough_thread(): """ Background thread that reads the passthrough data. """ self.assertEquals("For passthrough", comm.get_passthrough_data()) self.assertEquals("Passthrough again", comm.get_passthrough_data()) thread = threading.Thread(target=passthrough_thread) thread.start() comm.start_maintenance_mode() self.assertEquals("OK", comm.get_maintenance_data()) comm.send_maintenance_data("error list\r\n") self.assertEquals("the list\n", comm.get_maintenance_data()) comm.stop_maintenance_mode() thread.join()
def test_maintenance_mode(self): """ Test the maintenance mode. """ serial_mock = SerialMock([sin(master_api.to_cli_mode().create_input(0)), sout("OK"), sin("error list\r\n"), sout("the list\n"), sin("exit\r\n")]) comm = MasterCommunicator(serial_mock, init_master=False) comm.start() comm.start_maintenance_mode() try: comm.send_passthrough_data("test") self.assertTrue(False) except InMaintenanceModeException: pass try: comm.do_command(None, None) self.assertTrue(False) except InMaintenanceModeException: pass self.assertEquals("OK", comm.get_maintenance_data()) comm.send_maintenance_data("error list\r\n") self.assertEquals("the list\n", comm.get_maintenance_data()) comm.stop_maintenance_mode()
def test_maintenance_mode(self): """ Test the maintenance mode. """ serial_mock = SerialMock([ sin(master_api.to_cli_mode().create_input(0)), sout("OK"), sin("error list\r\n"), sout("the list\n"), sin("exit\r\n") ]) comm = MasterCommunicator(serial_mock, init_master=False) comm.start() comm.start_maintenance_mode() try: comm.send_passthrough_data("test") self.assertTrue(False) except InMaintenanceModeException: pass try: comm.do_command(None, None) self.assertTrue(False) except InMaintenanceModeException: pass self.assertEquals("OK", comm.get_maintenance_data()) comm.send_maintenance_data("error list\r\n") self.assertEquals("the list\n", comm.get_maintenance_data()) comm.stop_maintenance_mode()