mirror of
https://github.com/home-assistant/core.git
synced 2025-08-14 01:55:18 +02:00
Add requitements for tests.
This commit is contained in:
@@ -631,7 +631,6 @@ omit =
|
|||||||
homeassistant/components/weather/buienradar.py
|
homeassistant/components/weather/buienradar.py
|
||||||
homeassistant/components/weather/metoffice.py
|
homeassistant/components/weather/metoffice.py
|
||||||
homeassistant/components/weather/openweathermap.py
|
homeassistant/components/weather/openweathermap.py
|
||||||
homeassistant/components/weather/yweather.py
|
|
||||||
homeassistant/components/weather/zamg.py
|
homeassistant/components/weather/zamg.py
|
||||||
homeassistant/components/zeroconf.py
|
homeassistant/components/zeroconf.py
|
||||||
homeassistant/components/zwave/util.py
|
homeassistant/components/zwave/util.py
|
||||||
|
@@ -125,27 +125,27 @@ class YahooWeatherWeather(WeatherEntity):
|
|||||||
@property
|
@property
|
||||||
def pressure(self):
|
def pressure(self):
|
||||||
"""Return the pressure."""
|
"""Return the pressure."""
|
||||||
return self._data.yahoo.Atmosphere['pressure']
|
return float(self._data.yahoo.Atmosphere['pressure'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def humidity(self):
|
def humidity(self):
|
||||||
"""Return the humidity."""
|
"""Return the humidity."""
|
||||||
return self._data.yahoo.Atmosphere['humidity']
|
return int(self._data.yahoo.Atmosphere['humidity'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def visibility(self):
|
def visibility(self):
|
||||||
"""Return the visibility."""
|
"""Return the visibility."""
|
||||||
return self._data.yahoo.Atmosphere['visibility']
|
return float(self._data.yahoo.Atmosphere['visibility'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wind_speed(self):
|
def wind_speed(self):
|
||||||
"""Return the wind speed."""
|
"""Return the wind speed."""
|
||||||
return self._data.yahoo.Wind['speed']
|
return float(self._data.yahoo.Wind['speed'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wind_bearing(self):
|
def wind_bearing(self):
|
||||||
"""Return the wind direction."""
|
"""Return the wind direction."""
|
||||||
return self._data.yahoo.Wind['direction']
|
return int(self._data.yahoo.Wind['direction'])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def attribution(self):
|
def attribution(self):
|
||||||
|
@@ -180,3 +180,6 @@ warrant==0.5.0
|
|||||||
|
|
||||||
# homeassistant.components.sensor.yahoo_finance
|
# homeassistant.components.sensor.yahoo_finance
|
||||||
yahoo-finance==1.4.0
|
yahoo-finance==1.4.0
|
||||||
|
|
||||||
|
# homeassistant.components.weather.yweather
|
||||||
|
yahooweather==0.9
|
||||||
|
@@ -2,15 +2,13 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import requests_mock
|
from unittest.mock import patch
|
||||||
from unittest.mock import patch, MagicMock
|
|
||||||
|
import requests_mock # pylint: disable=import-error
|
||||||
|
|
||||||
#from homeassistant.components import weather
|
|
||||||
from homeassistant.components.weather import yweather
|
|
||||||
from homeassistant.components.weather import (
|
from homeassistant.components.weather import (
|
||||||
ATTR_WEATHER_ATTRIBUTION, ATTR_WEATHER_HUMIDITY, ATTR_WEATHER_OZONE,
|
ATTR_WEATHER_HUMIDITY, ATTR_WEATHER_PRESSURE, ATTR_WEATHER_TEMPERATURE,
|
||||||
ATTR_WEATHER_PRESSURE, ATTR_WEATHER_TEMPERATURE, ATTR_WEATHER_WIND_BEARING,
|
ATTR_WEATHER_WIND_BEARING, ATTR_WEATHER_WIND_SPEED)
|
||||||
ATTR_WEATHER_WIND_SPEED, ATTR_FORECAST, ATTR_FORECAST_TEMP)
|
|
||||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||||
from homeassistant.setup import setup_component
|
from homeassistant.setup import setup_component
|
||||||
|
|
||||||
@@ -21,19 +19,22 @@ def mock_responses(mock):
|
|||||||
"""Mock responses for Yahoo Weather."""
|
"""Mock responses for Yahoo Weather."""
|
||||||
base_url = 'https://query.yahooapis.com/v1/public/yql'
|
base_url = 'https://query.yahooapis.com/v1/public/yql'
|
||||||
mock.get(base_url +
|
mock.get(base_url +
|
||||||
'?q=SELECT+woeid+FROM+geo.places+WHERE+text+%3D+%27%2832.87336'+
|
'?q=SELECT+woeid+FROM+geo.places+WHERE+text+%3D+%27%2832.87336' +
|
||||||
'%2C-117.22743%29%27&format=json',
|
'%2C-117.22743%29%27&format=json',
|
||||||
text=load_fixture('yahooweather.json'))
|
text=load_fixture('yahooweather.json'))
|
||||||
|
|
||||||
def _yql_queryMock(yql):
|
|
||||||
|
def _yql_queryMock(yql): # pylint: disable=invalid-name
|
||||||
"""Mock yahoo query language query."""
|
"""Mock yahoo query language query."""
|
||||||
return ('{"query": {"count": 1, "created": "2017-11-17T13:40:47Z", '
|
return ('{"query": {"count": 1, "created": "2017-11-17T13:40:47Z", '
|
||||||
'"lang": "en-US", "results": {"place": {"woeid": "23511632"}}}}')
|
'"lang": "en-US", "results": {"place": {"woeid": "23511632"}}}}')
|
||||||
|
|
||||||
def get_woeidMock(lat, lon):
|
|
||||||
|
def get_woeidMock(lat, lon): # pylint: disable=invalid-name
|
||||||
"""Mock get woeid Where On Earth Identifiers."""
|
"""Mock get woeid Where On Earth Identifiers."""
|
||||||
return '23511632'
|
return '23511632'
|
||||||
|
|
||||||
|
|
||||||
class YahooWeatherMock():
|
class YahooWeatherMock():
|
||||||
"""Mock class for the YahooWeather object."""
|
"""Mock class for the YahooWeather object."""
|
||||||
|
|
||||||
@@ -43,43 +44,41 @@ class YahooWeatherMock():
|
|||||||
self.temp_unit = temp_unit
|
self.temp_unit = temp_unit
|
||||||
self._data = json.loads(load_fixture('yahooweather.json'))
|
self._data = json.loads(load_fixture('yahooweather.json'))
|
||||||
|
|
||||||
def updateWeather(self):
|
# pylint: disable=no-self-use
|
||||||
|
def updateWeather(self): # pylint: disable=invalid-name
|
||||||
"""Return sample values."""
|
"""Return sample values."""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def RawData(self):
|
def RawData(self): # pylint: disable=invalid-name
|
||||||
"""Raw Data."""
|
"""Raw Data."""
|
||||||
if self.woeid == '12345':
|
if self.woeid == '12345':
|
||||||
return json.loads('[]')
|
return json.loads('[]')
|
||||||
return self._data
|
return self._data
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Now(self):
|
def Now(self): # pylint: disable=invalid-name
|
||||||
"""Current weather data."""
|
"""Current weather data."""
|
||||||
if self.woeid == '111':
|
if self.woeid == '111':
|
||||||
raise ValueError
|
raise ValueError
|
||||||
return None
|
|
||||||
return self._data['query']['results']['channel']['item']['condition']
|
return self._data['query']['results']['channel']['item']['condition']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Atmosphere(self):
|
def Atmosphere(self): # pylint: disable=invalid-name
|
||||||
"""Atmosphere weather data."""
|
"""Atmosphere weather data."""
|
||||||
return self._data['query']['results']['channel']['atmosphere']
|
return self._data['query']['results']['channel']['atmosphere']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Wind(self):
|
def Wind(self): # pylint: disable=invalid-name
|
||||||
"""Wind weather data."""
|
"""Wind weather data."""
|
||||||
return self._data['query']['results']['channel']['wind']
|
return self._data['query']['results']['channel']['wind']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def Forecast(self):
|
def Forecast(self): # pylint: disable=invalid-name
|
||||||
"""Forecast data 0-5 Days."""
|
"""Forecast data 0-5 Days."""
|
||||||
if self.woeid == '123123':
|
if self.woeid == '123123':
|
||||||
raise ValueError
|
raise ValueError
|
||||||
else:
|
return self._data['query']['results']['channel']['item']['forecast']
|
||||||
return self._data['query']['results']['channel']['item']['forecast']
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class TestWeather(unittest.TestCase):
|
class TestWeather(unittest.TestCase):
|
||||||
|
Reference in New Issue
Block a user