diff --git a/tests/test_unsubscribe.py b/tests/test_unsubscribe.py index f7bbb21..1dfbb85 100644 --- a/tests/test_unsubscribe.py +++ b/tests/test_unsubscribe.py @@ -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. @@ -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: """