"""Real Home Assistant fixtures, isolated from the offline boundary doubles.""" from unittest.mock import patch import pytest from homeassistant.core import ServiceRegistry from pytest_homeassistant_custom_component.common import MockConfigEntry @pytest.fixture(autouse=True) def custom_integrations(enable_custom_integrations): """Let HA discover custom_components/heating_mpc in this checkout.""" @pytest.fixture(autouse=True) def no_actuator_calls(): """Reject every HA service call during all tested observer lifecycle paths.""" with patch.object(ServiceRegistry, "async_call", side_effect=AssertionError( "The shadow integration must never call HA services" )) as calls: yield calls calls.assert_not_called() @pytest.fixture def entry(): return MockConfigEntry( domain="heating_mpc", version=2, unique_id="home_heating", data={"climate_entity": "climate.reference", "heater_entity": "switch.boiler", "room_entities": ["sensor.room"], "outside_temperature_sources": ["sensor.outside"], "weights": {"sensor.room": 1.0}, "horizon_minutes": 60}, ) @pytest.fixture def inputs(hass): hass.states.async_set("sensor.room", "20", {"unit_of_measurement": "°C"}) hass.states.async_set("sensor.outside", "5", {"unit_of_measurement": "°C"}) hass.states.async_set("switch.boiler", "off") hass.states.async_set("climate.reference", "heat", {"temperature": 22, "preset_mode": "comfort"})