From d1ad1c47e6d3c9c21089f5e2d4d58fe08a7ce865 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 4 Aug 2023 01:07:11 +0200 Subject: [PATCH] Fix zha test RuntimeWarnings (#97733) --- tests/components/zha/test_config_flow.py | 3 +++ tests/components/zha/test_gateway.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/components/zha/test_config_flow.py b/tests/components/zha/test_config_flow.py index 17665994806..8e071247872 100644 --- a/tests/components/zha/test_config_flow.py +++ b/tests/components/zha/test_config_flow.py @@ -80,6 +80,9 @@ def mock_app(): "can_rewrite_custom_eui64": False, } } + mock_app.add_listener = MagicMock() + mock_app.groups = MagicMock() + mock_app.devices = MagicMock() with patch( "zigpy.application.ControllerApplication.new", AsyncMock(return_value=mock_app) diff --git a/tests/components/zha/test_gateway.py b/tests/components/zha/test_gateway.py index c58aaedcbbc..b9fcd4b6932 100644 --- a/tests/components/zha/test_gateway.py +++ b/tests/components/zha/test_gateway.py @@ -324,12 +324,15 @@ async def test_gateway_initialize_bellows_thread( zha_gateway._config.setdefault("zigpy_config", {}).update(config_override) with patch( - "bellows.zigbee.application.ControllerApplication.new", - new=AsyncMock(), - ) as mock_new: + "bellows.zigbee.application.ControllerApplication.new" + ) as controller_app_mock: + mock = AsyncMock() + mock.add_listener = MagicMock() + mock.groups = MagicMock() + controller_app_mock.return_value = mock await zha_gateway.async_initialize() - assert mock_new.mock_calls[0].args[0]["use_thread"] is thread_state + assert controller_app_mock.mock_calls[0].args[0]["use_thread"] is thread_state @pytest.mark.parametrize(