Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for the PUBLISH+UNSUBACK case #236

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading