mirror of
https://github.com/home-assistant/core.git
synced 2026-09-28 02:18:10 -04:00
Bump pyControl4 to 2.0.2 (#176050)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
90dbf1a7a9
commit
af883932bb
@@ -1,6 +1,7 @@
|
||||
"""Common fixtures for the Control4 tests."""
|
||||
|
||||
from collections.abc import AsyncGenerator, Generator
|
||||
import json
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import pytest
|
||||
@@ -54,16 +55,18 @@ def mock_c4_account() -> Generator[MagicMock]:
|
||||
),
|
||||
):
|
||||
mock_account = mock_account_class.return_value
|
||||
mock_account.getAccountBearerToken = AsyncMock()
|
||||
mock_account.getAccountControllers = AsyncMock(
|
||||
mock_account.get_account_bearer_token = AsyncMock()
|
||||
mock_account.get_account_controllers = AsyncMock(
|
||||
return_value={
|
||||
"controllerCommonName": "control4_model_00AA00AA00AA",
|
||||
"href": "https://apis.control4.com/account/v3/rest/accounts/000000",
|
||||
"name": "Name",
|
||||
}
|
||||
)
|
||||
mock_account.getDirectorBearerToken = AsyncMock(return_value={"token": "test"})
|
||||
mock_account.getControllerOSVersion = AsyncMock(return_value="3.2.0")
|
||||
mock_account.get_director_bearer_token = AsyncMock(
|
||||
return_value={"token": "test", "validSeconds": 86400}
|
||||
)
|
||||
mock_account.get_controller_os_version = AsyncMock(return_value="3.2.0")
|
||||
yield mock_account
|
||||
|
||||
|
||||
@@ -80,14 +83,12 @@ def mock_c4_director() -> Generator[MagicMock]:
|
||||
),
|
||||
):
|
||||
mock_director = mock_director_class.return_value
|
||||
# Multi-platform setup: media room, climate room, shared devices
|
||||
# Note: The API returns JSON strings, so we load fixtures as strings
|
||||
mock_director.getAllItemInfo = AsyncMock(
|
||||
return_value=load_fixture("director_all_items.json", DOMAIN)
|
||||
)
|
||||
mock_director.getUiConfiguration = AsyncMock(
|
||||
return_value=load_fixture("ui_configuration.json", DOMAIN)
|
||||
all_items = json.loads(load_fixture("director_all_items.json", DOMAIN))
|
||||
mock_director.get_all_item_info = AsyncMock(return_value=all_items)
|
||||
mock_director.get_ui_configuration = AsyncMock(
|
||||
return_value=json.loads(load_fixture("ui_configuration.json", DOMAIN))
|
||||
)
|
||||
mock_director.get_item_variables = AsyncMock(return_value=[])
|
||||
yield mock_director
|
||||
|
||||
|
||||
@@ -157,12 +158,12 @@ def mock_c4_climate() -> Generator[MagicMock]:
|
||||
"homeassistant.components.control4.climate.C4Climate", autospec=True
|
||||
) as mock_class:
|
||||
mock_instance = mock_class.return_value
|
||||
mock_instance.setHvacMode = AsyncMock()
|
||||
mock_instance.setHeatSetpointF = AsyncMock()
|
||||
mock_instance.setCoolSetpointF = AsyncMock()
|
||||
mock_instance.setFanMode = AsyncMock()
|
||||
mock_instance.setHeatSetpointC = AsyncMock()
|
||||
mock_instance.setCoolSetpointC = AsyncMock()
|
||||
mock_instance.set_hvac_mode = AsyncMock()
|
||||
mock_instance.set_heat_setpoint_f = AsyncMock()
|
||||
mock_instance.set_cool_setpoint_f = AsyncMock()
|
||||
mock_instance.set_fan_mode = AsyncMock()
|
||||
mock_instance.set_heat_setpoint_c = AsyncMock()
|
||||
mock_instance.set_cool_setpoint_c = AsyncMock()
|
||||
yield mock_instance
|
||||
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ async def test_set_hvac_mode(
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_HVAC_MODE: hvac_mode},
|
||||
blocking=True,
|
||||
)
|
||||
mock_c4_climate.setHvacMode.assert_called_once_with(expected_c4_mode)
|
||||
mock_c4_climate.set_hvac_mode.assert_called_once_with(expected_c4_mode)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -265,7 +265,7 @@ async def test_set_hvac_mode(
|
||||
temperature=72.5,
|
||||
humidity=45,
|
||||
),
|
||||
"setHeatSetpointF",
|
||||
"set_heat_setpoint_f",
|
||||
id="heat",
|
||||
),
|
||||
pytest.param(
|
||||
@@ -275,7 +275,7 @@ async def test_set_hvac_mode(
|
||||
temperature=74.0,
|
||||
cool_setpoint=72.0,
|
||||
),
|
||||
"setCoolSetpointF",
|
||||
"set_cool_setpoint_f",
|
||||
id="cool",
|
||||
),
|
||||
],
|
||||
@@ -330,8 +330,8 @@ async def test_set_temperature_range_auto_mode(
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
mock_c4_climate.setHeatSetpointF.assert_called_once_with(65.0)
|
||||
mock_c4_climate.setCoolSetpointF.assert_called_once_with(78.0)
|
||||
mock_c4_climate.set_heat_setpoint_f.assert_called_once_with(65.0)
|
||||
mock_c4_climate.set_cool_setpoint_f.assert_called_once_with(78.0)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mock_climate_variables", [{}])
|
||||
@@ -482,7 +482,7 @@ async def test_set_fan_mode(
|
||||
blocking=True,
|
||||
)
|
||||
# Verify the Control4 API is called with the C4 format ("On" not "on")
|
||||
mock_c4_climate.setFanMode.assert_called_once_with("On")
|
||||
mock_c4_climate.set_fan_mode.assert_called_once_with("On")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -530,14 +530,14 @@ async def test_fan_mode_not_supported(
|
||||
[
|
||||
pytest.param(
|
||||
_make_climate_data(hvac_state="Off", hvac_mode="Heat"),
|
||||
"setHeatSetpointF",
|
||||
"setHeatSetpointC",
|
||||
"set_heat_setpoint_f",
|
||||
"set_heat_setpoint_c",
|
||||
id="fahrenheit_heat_calls_F_not_C",
|
||||
),
|
||||
pytest.param(
|
||||
_make_climate_data(hvac_state="Cool", hvac_mode="Cool"),
|
||||
"setCoolSetpointF",
|
||||
"setCoolSetpointC",
|
||||
"set_cool_setpoint_f",
|
||||
"set_cool_setpoint_c",
|
||||
id="fahrenheit_cool_calls_F_not_C",
|
||||
),
|
||||
],
|
||||
|
||||
@@ -80,7 +80,7 @@ async def test_user_flow_errors(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
mock_c4_account.getAccountBearerToken.side_effect = exception
|
||||
mock_c4_account.get_account_bearer_token.side_effect = exception
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@@ -94,7 +94,7 @@ async def test_user_flow_errors(
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": error}
|
||||
|
||||
mock_c4_account.getAccountBearerToken.side_effect = None
|
||||
mock_c4_account.get_account_bearer_token.side_effect = None
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@@ -130,7 +130,7 @@ async def test_user_flow_director_errors(
|
||||
DOMAIN, context={"source": SOURCE_USER}
|
||||
)
|
||||
|
||||
mock_c4_director.getAllItemInfo.side_effect = exception
|
||||
mock_c4_director.get_all_item_info.side_effect = exception
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
@@ -144,7 +144,7 @@ async def test_user_flow_director_errors(
|
||||
assert result["type"] is FlowResultType.FORM
|
||||
assert result["errors"] == {"base": error}
|
||||
|
||||
mock_c4_director.getAllItemInfo.side_effect = None
|
||||
mock_c4_director.get_all_item_info.side_effect = None
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
|
||||
@@ -93,7 +93,7 @@ def mock_c4_blind() -> Generator[MagicMock]:
|
||||
mock_instance.open = AsyncMock()
|
||||
mock_instance.close = AsyncMock()
|
||||
mock_instance.stop = AsyncMock()
|
||||
mock_instance.setLevelTarget = AsyncMock()
|
||||
mock_instance.set_level_target = AsyncMock()
|
||||
yield mock_instance
|
||||
|
||||
|
||||
@@ -245,14 +245,14 @@ async def test_set_cover_position(
|
||||
hass: HomeAssistant,
|
||||
mock_c4_blind: MagicMock,
|
||||
) -> None:
|
||||
"""Test setting cover position calls setLevelTarget with the requested value."""
|
||||
"""Test setting cover position calls set_level_target with the requested value."""
|
||||
await hass.services.async_call(
|
||||
COVER_DOMAIN,
|
||||
SERVICE_SET_COVER_POSITION,
|
||||
{ATTR_ENTITY_ID: ENTITY_ID, ATTR_POSITION: 75},
|
||||
blocking=True,
|
||||
)
|
||||
mock_c4_blind.setLevelTarget.assert_called_once_with(75)
|
||||
mock_c4_blind.set_level_target.assert_called_once_with(75)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mock_cover_variables", [{}])
|
||||
|
||||
Reference in New Issue
Block a user