Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

Commit 72c798d

Browse files
authored
fix methods on 3.4, 3.5 (#100)
1 parent d810b0c commit 72c798d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

azure-iot-device/azure/iot/device/iothub/pipeline/pipeline_stages_iothub_mqtt.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ def _handle_pipeline_event(self, event):
157157
rid = mqtt_topic_iothub.get_method_request_id_from_topic(topic)
158158
method_name = mqtt_topic_iothub.get_method_name_from_topic(topic)
159159
method_received = MethodRequest(
160-
request_id=rid, name=method_name, payload=json.loads(event.payload)
160+
request_id=rid,
161+
name=method_name,
162+
payload=json.loads(event.payload.decode("utf-8")),
161163
)
162164
self.handle_pipeline_event(pipeline_events_iothub.MethodRequest(method_received))
163165

azure-iot-device/tests/iothub/pipeline/test_pipeline_stages_iothub_mqtt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
fake_method_request_topic = "$iothub/methods/POST/{}/?$rid={}".format(
8080
fake_method_name, fake_request_id
8181
)
82-
fake_method_request_payload = "{}"
82+
fake_method_request_payload = "{}".encode("utf-8")
8383

8484

8585
api_version = "2018-06-30"
@@ -702,4 +702,6 @@ def test_puts_mqtt_payload_in_method_request_payload(
702702
):
703703
stage.handle_pipeline_event(method_request_event)
704704
new_event = stage.previous.handle_pipeline_event.call_args[0][0]
705-
assert new_event.method_request.payload == json.loads(fake_method_request_payload)
705+
assert new_event.method_request.payload == json.loads(
706+
fake_method_request_payload.decode("utf-8")
707+
)

0 commit comments

Comments
 (0)