hass-core/tests/components/weatherflow_cloud/conftest.py
Jeef bc20e7900c
WeatherFlow Forecast (REST API) (#106615)
* rebase off dev

* Update homeassistant/components/weatherflow_cloud/const.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Addressing 1st round of PR Comments

* Update homeassistant/components/weatherflow_cloud/config_flow.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* addressing PR Comments

* fixing last comment that i can see

* Update homeassistant/components/weatherflow_cloud/coordinator.py

OOPS

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Update homeassistant/components/weatherflow_cloud/weather.py

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Update homeassistant/components/weatherflow_cloud/coordinator.py

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* switching to station id

* Update homeassistant/components/weatherflow_cloud/strings.json

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* addressing PR

* Updated tests to be better

* Updated tests accordingly

* REAuth flow and tests added

* Update homeassistant/components/weatherflow_cloud/strings.json

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Update homeassistant/components/weatherflow_cloud/coordinator.py

Co-authored-by: G Johansson <goran.johansson@shiftit.se>

* Addressing PR comments

* Apply suggestions from code review

* ruff fix

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Co-authored-by: G Johansson <goran.johansson@shiftit.se>
2024-02-26 22:40:21 +01:00

57 lines
1.6 KiB
Python

"""Common fixtures for the WeatherflowCloud tests."""
from collections.abc import Generator
from unittest.mock import AsyncMock, Mock, patch
from aiohttp import ClientResponseError
import pytest
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.weatherflow_cloud.async_setup_entry",
return_value=True,
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture
def mock_get_stations() -> Generator[AsyncMock, None, None]:
"""Mock get_stations with a sequence of responses."""
side_effects = [
True,
]
with patch(
"weatherflow4py.api.WeatherFlowRestAPI.async_get_stations",
side_effect=side_effects,
) as mock_get_stations:
yield mock_get_stations
@pytest.fixture
def mock_get_stations_500_error() -> Generator[AsyncMock, None, None]:
"""Mock get_stations with a sequence of responses."""
side_effects = [
ClientResponseError(Mock(), (), status=500),
True,
]
with patch(
"weatherflow4py.api.WeatherFlowRestAPI.async_get_stations",
side_effect=side_effects,
) as mock_get_stations:
yield mock_get_stations
@pytest.fixture
def mock_get_stations_401_error() -> Generator[AsyncMock, None, None]:
"""Mock get_stations with a sequence of responses."""
side_effects = [ClientResponseError(Mock(), (), status=401), True, True, True]
with patch(
"weatherflow4py.api.WeatherFlowRestAPI.async_get_stations",
side_effect=side_effects,
) as mock_get_stations:
yield mock_get_stations