Просмотр исходного кода

Update config_flow unit tests for change in HA 2024.1.2

HA 2024.1.2 now includes minor_version in the config, even when the
integration did not set it.  minor_version was added in HA 2024.1.0,
so it is not set by this integration yet.

Update the unit tests for this change in HA behaviour, and update the
pytest-home-assistant-custom-component version to ensure HA 2024.1.2
or later is used in the tests.
Jason Rumney 2 лет назад
Родитель
Сommit
9da9bfe617
2 измененных файлов с 8 добавлено и 2 удалено
  1. 1 1
      requirements-dev.txt
  2. 7 1
      tests/test_config_flow.py

+ 1 - 1
requirements-dev.txt

@@ -2,7 +2,7 @@ black
 fuzzywuzzy
 isort
 levenshtein
-pytest-homeassistant-custom-component~=0.13.54
+pytest-homeassistant-custom-component~=0.13.88
 pytest
 pytest-asyncio
 pytest-cov

+ 7 - 1
tests/test_config_flow.py

@@ -4,6 +4,7 @@ from unittest.mock import ANY, AsyncMock, MagicMock, patch
 import pytest
 import voluptuous as vol
 from homeassistant.const import CONF_HOST, CONF_NAME
+from homeassistant.data_entry_flow import FlowResultType
 from pytest_homeassistant_custom_component.common import MockConfigEntry
 
 from custom_components.tuya_local import (
@@ -252,6 +253,8 @@ async def test_async_test_connection_valid(mock_device, hass):
     """Test that device is returned when connection is valid."""
     mock_instance = AsyncMock()
     mock_instance.has_returned_state = True
+    mock_instance.pause = MagicMock()
+    mock_instance.resume = MagicMock()
     mock_device.return_value = mock_instance
     hass.data[DOMAIN] = {"deviceid": {"device": mock_instance}}
 
@@ -275,6 +278,8 @@ async def test_async_test_connection_for_subdevice_valid(mock_device, hass):
     """Test that subdevice is returned when connection is valid."""
     mock_instance = AsyncMock()
     mock_instance.has_returned_state = True
+    mock_instance.pause = MagicMock()
+    mock_instance.resume = MagicMock()
     mock_device.return_value = mock_instance
     hass.data[DOMAIN] = {"subdeviceid": {"device": mock_instance}}
 
@@ -488,8 +493,9 @@ async def test_flow_choose_entities_creates_config_entry(hass, bypass_setup):
         )
         expected = {
             "version": 13,
+            "minor_version": ANY,
             "context": {"source": "choose_entities"},
-            "type": "create_entry",
+            "type": FlowResultType.CREATE_ENTRY,
             "flow_id": ANY,
             "handler": DOMAIN,
             "title": "test",