From a0b6dd4693a534d91c11df2a7096f7760d211bfb Mon Sep 17 00:00:00 2001 From: DeerMaximum Date: Fri, 17 Nov 2023 22:33:24 +0100 Subject: [PATCH] Fix tests --- tests/__init__.py | 1 + tests/conftest.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/tests/__init__.py b/tests/__init__.py index 6a892b7..f279e75 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,6 +5,7 @@ COE_SEND_ANALOG_VALUES_PACKAGE = "ta_cmi.coe.CoE.send_analog_values" COE_SEND_DIGITAL_VALUES_PACKAGE = "ta_cmi.coe.CoE.send_digital_values" COEAPI_RAW_REQUEST_PACKAGE = "ta_cmi.coe_api.CoEAPI._make_request_get" +COE_VERSION_CHECK_PACKAGE = "ta_cmi.coe.CoE._check_version" SETUP_ENTRY_PACKAGE = "custom_components.ta_coe.async_setup_entry" STATE_AVAILABLE_PACKAGE = "homeassistant.core.StateMachine.get" STATE_SENDER_UPDATE_DIGITAL_MANUEL_PACKAGE = ( diff --git a/tests/conftest.py b/tests/conftest.py index 7af7623..7674e20 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,8 +1,24 @@ """Fixtures for testing.""" +from unittest import mock + import pytest +from tests import COE_VERSION_CHECK_PACKAGE + @pytest.fixture(autouse=True) def auto_enable_custom_integrations(enable_custom_integrations): """Enable enable_custom_integrations""" yield + + +@pytest.fixture(scope="session", autouse=True) +def patch_coe_server_check(request): + """Patch the ta-cmi CoE server version check.""" + patched = mock.patch(COE_VERSION_CHECK_PACKAGE) + patched.__enter__() + + def unpatch(): + patched.__exit__(None, None, None) + + request.addfinalizer(unpatch)