Skip to content

Commit

Permalink
Unit test for removing callback severance on 5-to-3 adapter (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera authored Nov 15, 2023
1 parent b8a0468 commit 084176c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/test_mqtt5to3_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,29 @@ def test_operation_sub_unsub(self):

connection.disconnect().result(TIMEOUT)

def test_operation_null_ack(self):
TEST_TOPIC = '/test/topic/adapter' + str(uuid.uuid4())
exception_occurred = False

client, mqtt5_callbacks = self._setup_direct_connect_mutual_tls()
mqtt311_callbacks = Mqtt311TestCallbacks()
connection = self._create_connection(client, mqtt311_callbacks)

# publish an offline packet so that the publish operation would be incomplete
published, packet_id = connection.publish(TEST_TOPIC, self.TEST_MSG, QoS.AT_LEAST_ONCE)

# Manually destroyed the connection so that the incomplete publish operation should fail with exception
del connection
try:
published.result(TIMEOUT)
except TimeoutError:
# Directly failed the test if the result time out
self.assertTrue(False, "Operation Time out. The connection does not fail the callback on destroy. ")
except Exception:
exception_occurred = True

assert (exception_occurred)

# ==============================================================
# MQTT311 CALLBACK TEST CASES
# ==============================================================
Expand Down

0 comments on commit 084176c

Please sign in to comment.