@@ -70,20 +70,20 @@ assert(connack.retcode == 0)
70
70
71
71
72
72
= MQTTSubscribe, packet instantiation
73
- sb = MQTT()/MQTTSubscribe(msgid=1,topic='newtopic',QOS=0, length=0)
73
+ sb = MQTT()/MQTTSubscribe(msgid=1, topics=[MQTTTopicQOS( topic='newtopic', QOS=1, length=0)] )
74
74
assert(sb.type == 8)
75
75
assert(sb.msgid == 1)
76
- assert(sb.topic == b'newtopic')
77
- assert(sb.length == 0)
78
- assert(sb[MQTTSubscribe].QOS == 0 )
76
+ assert(sb.topics[0]. topic == b'newtopic')
77
+ assert(sb.topics[0]. length == 0)
78
+ assert(sb[MQTTSubscribe][MQTTTopicQOS] .QOS == 1 )
79
79
80
80
= MQTTSubscribe, packet dissection
81
- s = b'\x82\t\x00\x01\x00\x04test\x00 '
81
+ s = b'\x82\t\x00\x01\x00\x04test\x01 '
82
82
subscribe = MQTT(s)
83
83
assert(subscribe.msgid == 1)
84
- assert(subscribe.length == 4)
85
- assert(subscribe.topic == b'test')
86
- assert(subscribe.QOS == 1)
84
+ assert(subscribe.topics[0]. length == 4)
85
+ assert(subscribe.topics[0]. topic == b'test')
86
+ assert(subscribe.topics[0]. QOS == 1)
87
87
88
88
89
89
= MQTTSuback, packet instantiation
@@ -98,6 +98,30 @@ suback = MQTT(s)
98
98
assert(suback.msgid == 1)
99
99
assert(suback.retcode == 0)
100
100
101
+ = MQTTUnsubscribe, packet instantiation
102
+ unsb = MQTT()/MQTTUnsubscribe(msgid=1, topics=[MQTTTopic(topic='newtopic',length=0)])
103
+ assert(unsb.type == 10)
104
+ assert(unsb.msgid == 1)
105
+ assert(unsb.topics[0].topic == b'newtopic')
106
+ assert(unsb.topics[0].length == 0)
107
+
108
+ = MQTTUnsubscribe, packet dissection
109
+ u = b'\xA2\x09\x00\x01\x00\x03\x61\x2F\x62'
110
+ unsubscribe = MQTT(u)
111
+ assert(unsubscribe.msgid == 1)
112
+ assert(unsubscribe.topics[0].length == 3)
113
+ assert(unsubscribe.topics[0].topic == b'a/b')
114
+
115
+ = MQTTUnsuback, packet instantiation
116
+ unsk = MQTT()/MQTTUnsuback(msgid=1)
117
+ assert(unsk.type == 11)
118
+ assert(unsk.msgid == 1)
119
+
120
+ = MQTTUnsuback, packet dissection
121
+ u = b'\xb0\x02\x00\x01'
122
+ unsuback = MQTT(u)
123
+ assert(unsuback.type == 11)
124
+ assert(unsuback.msgid == 1)
101
125
102
126
= MQTTPubrec, packet instantiation
103
127
pc = MQTT()/MQTTPubrec(msgid=1)
@@ -129,3 +153,7 @@ assert(type(MQTT().fieldtype['len'].randval() + 0) == int)
129
153
= MQTTUnsubscribe
130
154
u = MQTT(b'\xA2\x0C\x00\x01\x00\x03\x61\x2F\x62\x00\x03\x63\x2F\x64')
131
155
assert MQTTUnsubscribe in u and len(u.topics) == 2 and u.topics[1].topic == b"c/d"
156
+
157
+ = MQTTSubscribe
158
+ u = MQTT(b'\x82\x10\x00\x01\x00\x03\x61\x2F\x62\x02\x00\x03\x63\x2F\x64\x00')
159
+ assert MQTTSubscribe in u and len(u.topics) == 2 and u.topics[1].topic == b"c/d"
0 commit comments