diff --git a/tests/test_deviceapi.py b/tests/test_deviceapi.py index 3e8dc3c..be4dade 100644 --- a/tests/test_deviceapi.py +++ b/tests/test_deviceapi.py @@ -2,25 +2,27 @@ import pytest from asynctest import CoroutineMock -from httpx import AsyncClient, Client, Response +from google.protobuf.json_format import MessageToDict +from httpx import AsyncClient, Response from devolo_plc_api.device_api.deviceapi import DeviceApi +from devolo_plc_api.device_api.devolo_idl_proto_deviceapi_ledsettings_pb2 import LedSettingsGet class TestDeviceApi: @pytest.mark.asyncio async def test_async_get_led_setting(self, request): - ip = request.cls.ip - session = AsyncClient() - path = request.cls.device_info['_dvl-deviceapi._tcp.local.']['Path'] - version = request.cls.device_info['_dvl-deviceapi._tcp.local.']['Version'] - features = "led" - password = "password" - with patch("devolo_plc_api.clients.protobuf.Protobuf._async_get", new=CoroutineMock(return_value=Response)), \ patch("httpx.Response.aread", new=CoroutineMock(return_value=b"")): - device_api = DeviceApi(ip, session, path, version, features, password) + device_api = DeviceApi(request.cls.ip, + AsyncClient(), + request.cls.device_info['_dvl-deviceapi._tcp.local.']['Path'], + request.cls.device_info['_dvl-deviceapi._tcp.local.']['Version'], + "led", + "password") led_setting = await device_api.async_get_led_setting() - assert led_setting['state'] == "LED_ON" + assert led_setting == MessageToDict(LedSettingsGet(), + including_default_value_fields=True, + preserving_proto_field_name=True)