1

I just want to write a TestCase for WebSocketClientProtocol in the setUp and tearDown I think I setup correctly the Server.

All I want is test client connected to server and server send some message client will receive that's it.

Below is the code I tried to make but I don't go further from here

class WebSocketTest(unittest.TestCase):

    def setUp(self):
        factory = WebSocketServerFactory("ws://localhost:8000")
        self.listening_port = listenWS(factory)
        self.factory, self.port = factory, port

    def tearDown(self):
        self.listening_port.stopListening()

    def test_client_message(self):
        client_factory = TestClientProtocolFactory(
            url="ws://127.0.0.1:8000".format(self.port))
        connectWS(client_factory)
  • Not sure what you're asking here. Is an exception raised? Does the test hang? Can you manually connect to the test port manually (e.g. via telnet)? – Lex Scarisbrick Jul 21 '16 at 16:46
  • @LexScarisbrick sorry I don't know how to ask. I created the web socket server inside the test case and using when test case running server send some message to client and client will get that message. But Why don't know where to look and how to receive the message when server send... –  Jul 21 '16 at 16:48
  • Perhaps [this answer](http://stackoverflow.com/a/14844253/6084928) will help. – Lex Scarisbrick Jul 21 '16 at 16:53
  • @LexScarisbrick thanks I'll take look.. –  Jul 21 '16 at 16:58

0 Answers0