From acd7c3027ea607b154dc5465ccc8e9180eed50fc Mon Sep 17 00:00:00 2001 From: Tim Camise Date: Thu, 21 Sep 2023 13:23:18 -0700 Subject: [PATCH] Fix Set Setting URL in the Python SDK (#402) --- .../python/sdk_wireless_camera_control/docs/changelog.rst | 1 + .../sdk_wireless_camera_control/open_gopro/api/builders.py | 2 +- .../tests/unit/test_http_commands.py | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/demos/python/sdk_wireless_camera_control/docs/changelog.rst b/demos/python/sdk_wireless_camera_control/docs/changelog.rst index 283e4358..6da5f54d 100644 --- a/demos/python/sdk_wireless_camera_control/docs/changelog.rst +++ b/demos/python/sdk_wireless_camera_control/docs/changelog.rst @@ -13,6 +13,7 @@ Unreleased ---------- * Fix BLE notifications not being routed correctly * Don't hardcode media directory. Also append directory to filenames in media list. +* Fix malformed Set Setting HTTP url 0.14.0 (September-13-2022) -------------------------- diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/api/builders.py b/demos/python/sdk_wireless_camera_control/open_gopro/api/builders.py index 980b75d6..630d8e10 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/api/builders.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/api/builders.py @@ -991,9 +991,9 @@ async def set(self, value: ValueType) -> GoProResp: Returns: GoProResp: Status of set """ + value = value.value if isinstance(value, enum.Enum) else value url = self._endpoint.format(int(self._identifier), value) logger.info(Logger.build_log_tx_str(pretty_print(self._as_dict(value=value, endpoint=url)))) - value = value.value if isinstance(value, enum.Enum) else value # Send to camera if response := await self._communicator._http_get( url, diff --git a/demos/python/sdk_wireless_camera_control/tests/unit/test_http_commands.py b/demos/python/sdk_wireless_camera_control/tests/unit/test_http_commands.py index 35bc0b3f..c1a52169 100644 --- a/demos/python/sdk_wireless_camera_control/tests/unit/test_http_commands.py +++ b/demos/python/sdk_wireless_camera_control/tests/unit/test_http_commands.py @@ -7,6 +7,7 @@ import pytest +from open_gopro import Params from open_gopro.gopro_base import GoProBase camera_file = "100GOPRO/XXX.mp4" @@ -18,6 +19,12 @@ async def test_get_with_no_params(mock_wifi_communicator: GoProBase): assert response.url == "gopro/media/list" +@pytest.mark.asyncio +async def test_set_setting(mock_wifi_communicator: GoProBase): + response = await mock_wifi_communicator.http_setting.fps.set(Params.FPS.FPS_100) + assert response.url == "gopro/camera/setting?setting=3&option=2" + + @pytest.mark.asyncio async def test_get_with_params(mock_wifi_communicator: GoProBase): zoom = 99