"""Test the Portainer initial specific behavior.""" from unittest.mock import AsyncMock from pyportainer.exceptions import ( PortainerAuthenticationError, PortainerConnectionError, PortainerTimeoutError, ) import pytest from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant from . import setup_integration from tests.common import MockConfigEntry @pytest.mark.parametrize( ("exception", "expected_state"), [ (PortainerAuthenticationError("bad creds"), ConfigEntryState.SETUP_ERROR), (PortainerConnectionError("cannot connect"), ConfigEntryState.SETUP_RETRY), (PortainerTimeoutError("timeout"), ConfigEntryState.SETUP_RETRY), ], ) async def test_setup_exceptions( hass: HomeAssistant, mock_portainer_client: AsyncMock, mock_config_entry: MockConfigEntry, exception: Exception, expected_state: ConfigEntryState, ) -> None: """Test the _async_setup.""" mock_portainer_client.get_endpoints.side_effect = exception await setup_integration(hass, mock_config_entry) assert mock_config_entry.state == expected_state