Exemplo n.º 1
0
def basicUnitTest():
    #asyncio.set_event_loop(TestLoopEx())
    # server = EchoServerProtocol()
    # client = EchoClientProtocol()
    # transportToServer = MockTransportToProtocol(server)
    # transportToClient = MockTransportToProtocol(client)
    # server.connection_made(transportToClient)
    # client.connection_made(transportToServer)
    client = EchoClientProtocol()
    server = EchoServerProtocol()
    cTransport, sTransport = MockTransportToProtocol.CreateTransportPair(
        client, server)
    client.connection_made(cTransport)
    server.connection_made(sTransport)
    firstRequest = packetClass.RequestRecommandation()
    client.Request(firstRequest)
    assert server.serverstatus == 1
    assert client.clientstatus == 1
    #client.method(firstRequest)
    OneAnswer = packetClass.Answer()
    OneAnswer.answer = "oliy"
    OneAnswer.ID = 1
    client.method(OneAnswer)
    assert server.serverstatus == 2
    assert client.clientstatus == 2
Exemplo n.º 2
0
 def connection_made(self, transport):
     self.transport = transport
     self.deserializer = PacketType.Deserializer()
     # self.packet = RequestRecommandation()
     # RequestRecommandation().request = "request recommandation"
     # packetBytes = self.packet.__serialize__()
     # self.transport.write(packetBytes)
     print("Client is connected to server")
     firstRequest = packetClass.RequestRecommandation()
     self.Request(firstRequest)