コード例 #1
0
ファイル: tests.py プロジェクト: cyberj/pulsar
 def testUpgrade(self):
     c = HttpClient()
     outcome = c.get(self.ws_echo)
     yield outcome
     ws = outcome.result
     response = ws.handshake
     self.assertEqual(response.status_code, 101)
     self.assertEqual(response.headers["upgrade"], "websocket")
     # Send a message to the websocket
     outcome = ws.execute("Hi there!")
     yield outcome
     response = outcome.result
     self.assertEqual(response.body, "Hi there!")
     self.assertFalse(response.masking_key)
コード例 #2
0
ファイル: tests.py プロジェクト: cyberj/pulsar
 def testBadRequests(self):
     c = HttpClient()
     outcome = c.post(self.ws_uri)
     yield outcome
     response = outcome.result
     self.assertEqual(response.status_code, 400)
     #
     outcome = c.get(self.ws_uri, headers=[("Sec-Websocket-Key", "")])
     yield outcome
     response = outcome.result
     self.assertEqual(response.status_code, 400)
     #
     outcome = c.get(self.ws_uri, headers=[("Sec-Websocket-Key", "bla")])
     yield outcome
     response = outcome.result
     self.assertEqual(response.status_code, 400)
     #
     outcome = c.get(self.ws_uri, headers=[("Sec-Websocket-version", "xxx")])
     yield outcome
     response = outcome.result
     self.assertEqual(response.status_code, 400)