From 243b46aadb6189c981be038b3ae8d0244fc7e6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Mon, 23 Jun 2025 14:09:52 +0200 Subject: [PATCH] test: adds test for ProxyClass This test timed out before implementing the changes. --- tests/client/test_proxy_class.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/client/test_proxy_class.py diff --git a/tests/client/test_proxy_class.py b/tests/client/test_proxy_class.py new file mode 100644 index 0000000..c674462 --- /dev/null +++ b/tests/client/test_proxy_class.py @@ -0,0 +1,22 @@ +import asyncio +from unittest.mock import AsyncMock, call, patch + +import pytest + +from pydase import components +from pydase.client.proxy_class import ProxyClass + + +@pytest.mark.asyncio +async def test_serialize_fallback_inside_event_loop() -> None: + loop = asyncio.get_running_loop() + mock_sio = AsyncMock() + proxy = ProxyClass(sio_client=mock_sio, loop=loop, reconnect=lambda: None) + + with patch.object( + components.DeviceConnection, "serialize", return_value={"value": {}} + ) as mock_fallback: + result = proxy.serialize() + + mock_fallback.assert_has_calls(calls=[call(), call()]) + assert isinstance(result, dict)