@@ -29,7 +29,7 @@ def handle_subscribe(client, user_data, topic, qos):
29
29
# short topic with remaining length encoded as single byte
30
30
(
31
31
"foo/bar" ,
32
- bytearray ([0x90 , 0x03 , 0x00 , 0x01 , 0x00 ]),
32
+ bytearray ([0x90 , 0x03 , 0x00 , 0x01 , 0x00 ]), # SUBACK
33
33
bytearray (
34
34
[
35
35
0x82 , # fixed header
@@ -52,7 +52,7 @@ def handle_subscribe(client, user_data, topic, qos):
52
52
# remaining length is encoded as 2 bytes due to long topic name.
53
53
(
54
54
"f" + "o" * 257 ,
55
- bytearray ([0x90 , 0x03 , 0x00 , 0x01 , 0x00 ]),
55
+ bytearray ([0x90 , 0x03 , 0x00 , 0x01 , 0x00 ]), # SUBACK
56
56
bytearray (
57
57
[
58
58
0x82 , # fixed header
@@ -68,11 +68,58 @@ def handle_subscribe(client, user_data, topic, qos):
68
68
+ [0x00 ] # QoS
69
69
),
70
70
),
71
+ # SUBSCRIBE responded to by PUBLISH followed by SUBACK
72
+ (
73
+ "foo/bar" ,
74
+ bytearray (
75
+ [
76
+ 0x30 , # PUBLISH
77
+ 0x0C ,
78
+ 0x00 ,
79
+ 0x07 ,
80
+ 0x66 ,
81
+ 0x6F ,
82
+ 0x6F ,
83
+ 0x2F ,
84
+ 0x62 ,
85
+ 0x61 ,
86
+ 0x72 ,
87
+ 0x66 ,
88
+ 0x6F ,
89
+ 0x6F ,
90
+ 0x90 , # SUBACK
91
+ 0x03 ,
92
+ 0x00 ,
93
+ 0x01 ,
94
+ 0x00 ,
95
+ ]
96
+ ),
97
+ bytearray (
98
+ [
99
+ 0x82 , # fixed header
100
+ 0x0C , # remaining length
101
+ 0x00 ,
102
+ 0x01 , # message ID
103
+ 0x00 ,
104
+ 0x07 , # topic length
105
+ 0x66 , # topic
106
+ 0x6F ,
107
+ 0x6F ,
108
+ 0x2F ,
109
+ 0x62 ,
110
+ 0x61 ,
111
+ 0x72 ,
112
+ 0x00 , # QoS
113
+ ]
114
+ ),
115
+ ),
71
116
]
72
117
73
118
74
119
@pytest .mark .parametrize (
75
- "topic,to_send,exp_recv" , testdata , ids = ["short_topic" , "long_topic" ]
120
+ "topic,to_send,exp_recv" ,
121
+ testdata ,
122
+ ids = ["short_topic" , "long_topic" , "publish_first" ],
76
123
)
77
124
def test_subscribe (topic , to_send , exp_recv ) -> None :
78
125
"""
0 commit comments