Skip to content

Commit d4b87d2

Browse files
authored
Merge pull request #236 from vladak/unsuback_vs_publish
add test for the PUBLISH+UNSUBACK case
2 parents c66e831 + 0cd7893 commit d4b87d2

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

tests/test_unsubscribe.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,49 @@ def handle_unsubscribe(client, user_data, topic, pid):
6868
+ [0x6F] * 257
6969
),
7070
),
71+
# UNSUBSCRIBE responded to by PUBLISH followed by UNSUBACK
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+
0xB0, # UNSUBACK
91+
0x02,
92+
0x00,
93+
0x01,
94+
]
95+
),
96+
bytearray(
97+
[
98+
0xA2, # fixed header
99+
0x0B, # remaining length
100+
0x00,
101+
0x01, # message ID
102+
0x00,
103+
0x07, # topic length
104+
0x66, # topic
105+
0x6F,
106+
0x6F,
107+
0x2F,
108+
0x62,
109+
0x61,
110+
0x72,
111+
]
112+
),
113+
),
71114
# use list of topics for more coverage. If the range was (1, 10000), that would be
72115
# long enough to use 3 bytes for remaining length, however that would make the test
73116
# run for many minutes even on modern systems, so 1000 is used instead.
@@ -95,7 +138,7 @@ def handle_unsubscribe(client, user_data, topic, pid):
95138
@pytest.mark.parametrize(
96139
"topic,to_send,exp_recv",
97140
testdata,
98-
ids=["short_topic", "long_topic", "topic_list_long"],
141+
ids=["short_topic", "long_topic", "publish_first", "topic_list_long"],
99142
)
100143
def test_unsubscribe(topic, to_send, exp_recv) -> None:
101144
"""

0 commit comments

Comments
 (0)