hass-core/tests/components/prosegur/test_init.py
Diogo Gomes c8fc2dc440
Add Camera platform to Prosegur (#76428)
* add camera to prosegur

* add tests

* address review

* better tests

* clean

* clean

* fix tests

* leftover from merge

* sorting missing

* Update homeassistant/components/prosegur/services.yaml

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

---------

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2023-02-26 20:25:55 -05:00

42 lines
973 B
Python

"""Tests prosegur setup."""
from unittest.mock import patch
import pytest
from homeassistant.core import HomeAssistant
from tests.test_util.aiohttp import AiohttpClientMocker
@pytest.mark.parametrize(
"error",
[
ConnectionRefusedError,
ConnectionError,
],
)
async def test_setup_entry_fail_retrieve(
hass: HomeAssistant, mock_config_entry, error
) -> None:
"""Test loading the Prosegur entry."""
mock_config_entry.add_to_hass(hass)
with patch(
"pyprosegur.auth.Auth.login",
side_effect=error,
):
assert not await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
async def test_unload_entry(
hass: HomeAssistant,
init_integration,
mock_config_entry,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Test unloading the Prosegur entry."""
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)