Skip to content

Commit

Permalink
MQTT operations should happen over WebSockets (Azure#366)
Browse files Browse the repository at this point in the history
* Integrate TQDM to show progress bar when simulator sends d2c messages

* remove unused loop varable

* Update progress bar descriptionb

* update twin reported properties during simulation

* update unit tests

* styling updates

* Using SDK Listener for Twin properties update

* merge from remote

* Structured mqtt formatting and eliminate dependency on six

* remove indent property not needed any more

* Support C2D Message decoding and Add TQDM for HTTP simulation

* Update MQTT operations to run on web sockets

* Remove duplicate test already in dev branch

* Device connection is automatic now

* Styling update
  • Loading branch information
avagraw committed Jul 28, 2021
1 parent 2d80089 commit d4cdceb
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions azext_iot/tests/iothub/test_iot_messaging_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,36 +106,6 @@ def test_uamqp_device_messaging(self):
checks=self.is_empty(),
)

utf_32_encoding = "utf-32"
string_payload = "Test payload encoding decoding"

# Send C2D Message with UTF-32 encoding
self.cmd(
"""iot device c2d-message send -d {} -n {} -g {} --data '{}' --cid {} --mid {} --ct {} --expiry {}
--ce {} --props {}""".format(
device_ids[0],
LIVE_HUB,
LIVE_RG,
string_payload,
test_cid,
test_mid,
test_ct,
test_et,
utf_32_encoding,
test_props,
),
checks=self.is_empty(),
)

result = self.cmd(
"iot device c2d-message receive -d {} --hub-name {} -g {}".format(
device_ids[0], LIVE_HUB, LIVE_RG
)
).get_output_in_json()

# Verify that the data was decoded correctly
assert result["data"] == string_payload

# Send C2D message via --login + application/json content ype

test_ct = "application/json"
Expand Down Expand Up @@ -299,6 +269,7 @@ def test_mqtt_device_direct_method_with_custom_response_status_payload(self):
from azext_iot.operations.hub import iot_simulate_device
from azext_iot._factory import iot_hub_service_factory
from azure.cli.core.mock import DummyCli
from time import sleep

cli_ctx = DummyCli()
client = iot_hub_service_factory(cli_ctx)
Expand All @@ -311,7 +282,7 @@ def test_mqtt_device_direct_method_with_custom_response_status_payload(self):
LIVE_HUB,
"complete",
"Testing direct method invocations when simulator is run with custom method response status and payload",
2,
4,
5,
"mqtt",
None,
Expand All @@ -324,6 +295,8 @@ def test_mqtt_device_direct_method_with_custom_response_status_payload(self):
return_handle=True,
)

sleep(MQTT_CLIENT_SETUP_TIME)

# invoke device method with response status and payload
result = self.cmd(
"iot hub invoke-device-method -d {} --method-name Test_Method_2 --login {}".format(
Expand Down

0 comments on commit d4cdceb

Please sign in to comment.