def test_terminate_on_msg_before_service_desc(): with create_upstream_context() as ctxt: msg = Message.RevokeBoardAvailable() ctxt.send_msg(msg) # other end has to close connection so check if socked is dead now, optionally a Notification can be sent before closing try: ctxt._socket.recv(0) uc.expect_message("Notification") ctxt.close() raise ValueError("RevokeBoardAvailable erroneously accepted") except: # try with the next message ctxt.close() with create_upstream_context() as ctxt: msg = Message.BoardAvailable("TestBoard","HermesAcceptanceTester") board_id = msg.data.get("BoardId") ctxt.send_msg(msg) # other end has to close connection so check if socked is dead now, optionally a Notification can be sent before closing try: ctxt._socket.recv(0) uc.expect_message("Notification") ctxt.close() raise ValueError("BoardAvailable erroneously accepted") except: # try with the next message ctxt.close() with create_upstream_context() as ctxt: msg = Message.TransportFinished(TransferState.COMPLETE, board_id) ctxt.send_msg(msg) # other end has to close connection so check if socked is dead now, optionally a Notification can be sent before closing try: ctxt._socket.recv(0) uc.expect_message("Notification") ctxt.close() raise ValueError("TransportFinished erroneously accepted") except: # try with the next message ctxt.close() with create_upstream_context() as ctxt: msg = Message.BoardForecast() ctxt.send_msg(msg) # other end has to close connection so check if socked is dead now, optionally a Notification can be sent before closing try: ctxt._socket.recv(0) uc.expect_message("Notification") ctxt.close() raise ValueError("TransportFinished erroneously accepted") except: # try with the next message ctxt.close()
def test_terminate_on_unexpected_transport_finished(): with create_upstream_context() as ctxt: ctxt.send_msg(Message.ServiceDescription("AcceptanceTest", 2)) ctxt.expect_message("ServiceDescription") msg = Message.TransportFinished(TransferState.COMPLETE, "some_guid") ctxt.send_msg(msg) # other end has to close connection so check if socked is dead now, optionally a Notification can be sent before closing try: ctxt._socket.recv(0) uc.expect_message("Notification") ctxt.close() raise ValueError("TransportFinished erroneously accepted after handshake") except: pass