mirror of
https://github.com/home-assistant/core.git
synced 2026-08-28 02:24:46 -05:00
33 lines
950 B
Python
33 lines
950 B
Python
"""Fixtures for Met weather testing."""
|
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
import pytest
|
|
|
|
|
|
def pytest_configure(config: pytest.Config) -> None:
|
|
"""Register the mark used to opt out of the autouse fixtures."""
|
|
config.addinivalue_line(
|
|
"markers", "disable_autouse_fixture: mark test to skip an autouse fixture"
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_weather():
|
|
"""Mock weather data."""
|
|
with patch("metno.MetWeatherData") as mock_data:
|
|
mock_data = mock_data.return_value
|
|
mock_data.fetching_data = AsyncMock(return_value=True)
|
|
mock_data.get_current_weather.return_value = {
|
|
"condition": "cloudy",
|
|
"temperature": 15,
|
|
"pressure": 100,
|
|
"humidity": 50,
|
|
"wind_speed": 10,
|
|
"wind_bearing": 90,
|
|
"dew_point": 12.1,
|
|
"uv_index": 1.1,
|
|
}
|
|
mock_data.get_forecast.return_value = {}
|
|
yield mock_data
|