"""Test Suez_water integration initialization.""" from unittest.mock import AsyncMock from homeassistant.components.suez_water.coordinator import PySuezError from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant from . import setup_integration from tests.common import MockConfigEntry async def test_initialization_invalid_credentials( hass: HomeAssistant, suez_client: AsyncMock, mock_config_entry: MockConfigEntry, ) -> None: """Test that suez_water can't be loaded with invalid credentials.""" suez_client.check_credentials.return_value = False await setup_integration(hass, mock_config_entry) assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR async def test_initialization_setup_api_error( hass: HomeAssistant, suez_client: AsyncMock, mock_config_entry: MockConfigEntry, ) -> None: """Test that suez_water needs to retry loading if api failed to connect.""" suez_client.check_credentials.side_effect = PySuezError("Test failure") await setup_integration(hass, mock_config_entry) assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY