@@ -96,6 +96,39 @@ async def test_async_setup_entry_with_comprehensive_unit_info(
9696 assert "CP: 01.08" in sw_version
9797
9898
99+ @pytest .mark .asyncio
100+ async def test_async_setup_entry_without_unit_info (hass , mock_config_entry , mock_coordinator ):
101+ """Test setup with failing unit info"""
102+
103+ with (
104+ patch ("custom_components.mitsubishi.MitsubishiController" ) as mock_controller_class ,
105+ patch (
106+ "custom_components.mitsubishi.MitsubishiDataUpdateCoordinator" ,
107+ return_value = mock_coordinator ,
108+ ),
109+ patch ("custom_components.mitsubishi.dr.async_get" ) as mock_device_registry ,
110+ patch .object (hass .config_entries , "async_forward_entry_setups" , return_value = None ),
111+ ):
112+ mock_controller = MagicMock ()
113+ mock_controller .fetch_status = MagicMock (return_value = True )
114+ mock_controller_class .return_value = mock_controller
115+
116+ # Mock device registry
117+ mock_registry = MagicMock ()
118+ mock_device_registry .return_value = mock_registry
119+
120+ mock_coordinator .get_unit_info = MagicMock (
121+ side_effect = requests .exceptions .HTTPError ("404 Client Error: Not Found for url" )
122+ )
123+
124+ result = await async_setup_entry (hass , mock_config_entry )
125+
126+ assert result is True
127+
128+ # Verify device registry was called with comprehensive info
129+ mock_registry .async_get_or_create .assert_called_once ()
130+
131+
99132@pytest .mark .asyncio
100133async def test_async_setup_entry_connection_failure (hass , mock_config_entry ):
101134 """Test setup when connection to device fails."""
0 commit comments