Skip to content

Commit

Permalink
Merge pull request #236 from vladak/unsuback_vs_publish
Browse files Browse the repository at this point in the history
add test for the PUBLISH+UNSUBACK case
  • Loading branch information
dhalbert authored Jan 19, 2025
2 parents c66e831 + 0cd7893 commit d4b87d2
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion tests/test_unsubscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,49 @@ def handle_unsubscribe(client, user_data, topic, pid):
+ [0x6F] * 257
),
),
# UNSUBSCRIBE responded to by PUBLISH followed by UNSUBACK
(
"foo/bar",
bytearray(
[
0x30, # PUBLISH
0x0C,
0x00,
0x07,
0x66,
0x6F,
0x6F,
0x2F,
0x62,
0x61,
0x72,
0x66,
0x6F,
0x6F,
0xB0, # UNSUBACK
0x02,
0x00,
0x01,
]
),
bytearray(
[
0xA2, # fixed header
0x0B, # remaining length
0x00,
0x01, # message ID
0x00,
0x07, # topic length
0x66, # topic
0x6F,
0x6F,
0x2F,
0x62,
0x61,
0x72,
]
),
),
# use list of topics for more coverage. If the range was (1, 10000), that would be
# long enough to use 3 bytes for remaining length, however that would make the test
# run for many minutes even on modern systems, so 1000 is used instead.
Expand Down Expand Up @@ -95,7 +138,7 @@ def handle_unsubscribe(client, user_data, topic, pid):
@pytest.mark.parametrize(
"topic,to_send,exp_recv",
testdata,
ids=["short_topic", "long_topic", "topic_list_long"],
ids=["short_topic", "long_topic", "publish_first", "topic_list_long"],
)
def test_unsubscribe(topic, to_send, exp_recv) -> None:
"""
Expand Down

0 comments on commit d4b87d2

Please sign in to comment.