Beispiel #1
0
 def test_ack_with_bad_json(self):
     """
     NOTE: this test differs from original, as we prefer throwing an error
     then silently ignore (read the ZEN).
     """
     with self.assertRaises(DecodeError):
         Packet.decode(b'6:::1+{"++]')
Beispiel #2
0
 def test_connect_with_querystring(self):
     msg = Packet.decode(b'1::/test:?test=1')
     self.assertMsg(msg, type="connect", endpoint="/test", qs={"test": ["1"]})
Beispiel #3
0
 def test_connect(self):
     msg = Packet.decode(b'1::/tobi')
     self.assertMsg(msg, type="connect", endpoint="/tobi", qs={})
Beispiel #4
0
 def test_heartbeat(self):
     msg = Packet.decode(b'2::')
     self.assertMsg(msg, type="heartbeat")
Beispiel #5
0
 def test_message_with_id_and_endpoint(self):
     msg = Packet.decode(b'3:5:/tobi')
     self.assertMsg(msg, type="message", id=b'5', ack=True, data=b"", endpoint="/tobi")
Beispiel #6
0
 def test_message(self):
     msg = Packet.decode(b'3:::woot')
     self.assertMsg(msg, type="message", data=b"woot")
Beispiel #7
0
 def test_event_with_data(self):
     msg = Packet.decode(b'5:::{"name":"edwald","args":[{"a": "b"},2,"3"]}')
     self.assertMsg(msg, type="event", name="edwald", args=[{"a": "b"}, 2, "3"])
Beispiel #8
0
 def test_error_with_reason(self):
     msg = Packet.decode(b"7:::0")
     self.assertMsg(msg, type="error", reason="transport not supported", advice="")
Beispiel #9
0
 def test_json_with_message_id_and_ack(self):
     msg = Packet.decode(b'4:1+::{"a":"b"}')
     self.assertMsg(msg, type="json", id=b'1', ack="data", data={"a": "b"})
Beispiel #10
0
 def test_json(self):
     msg = Packet.decode(b'4:::"2"')
     self.assertMsg(msg, type="json", data=b'2')
Beispiel #11
0
 def test_ack_with_args(self):
     msg = Packet.decode(b'6:::12+["woot","wa"]')
     self.assertMsg(msg, type="ack", ackid=b'12', args=["woot", "wa"])
Beispiel #12
0
 def test_ack(self):
     msg = Packet.decode(b"6:::140")
     self.assertMsg(msg, type="ack", ackid=b'140', args=[])
Beispiel #13
0
 def test_error_with_endpoint(self):
     msg = Packet.decode(b"7::/woot")
     self.assertMsg(msg, type="error", reason="", advice="", endpoint="/woot")
Beispiel #14
0
 def test_error_with_reason_and_advice(self):
     msg = Packet.decode(b"7:::2+0")
     self.assertMsg(msg, type="error", reason="unauthorized", advice="reconnect")
Beispiel #15
0
 def test_disconnect(self):
     msg = Packet.decode(b'0::/woot')
     self.assertMsg(msg, type="disconnect", endpoint="/woot")
Beispiel #16
0
 def test_event(self):
     msg = Packet.decode(b'5:::{"name":"woot"}')
     self.assertMsg(msg, type="event", name="woot", args=[])
Beispiel #17
0
 def test_decoding_newline(self):
     msg = Packet.decode(b'3:::\n')
     self.assertMsg(msg, type="message", data=b"\n")
Beispiel #18
0
 def test_error(self):
     msg = Packet.decode(b"7:::")
     self.assertMsg(msg, type="error", reason="", advice="")