mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Added and fixed yr tests
This commit is contained in:
parent
e29a2fa45a
commit
5005b20122
@ -28,7 +28,7 @@ SENSOR_TYPES = {
|
||||
'temperature': ['Temperature', '°C'],
|
||||
'windSpeed': ['Wind speed', 'm/s'],
|
||||
'windGust': ['Wind gust', 'm/s'],
|
||||
'pressure': ['Pressure', 'mbar'],
|
||||
'pressure': ['Pressure', 'hPa'],
|
||||
'windDirection': ['Wind direction', '°'],
|
||||
'humidity': ['Humidity', '%'],
|
||||
'fog': ['Fog', '%'],
|
||||
|
@ -43,37 +43,47 @@ class TestSensorYr:
|
||||
|
||||
state = self.hass.states.get('sensor.yr_symbol')
|
||||
|
||||
assert '46' == state.state
|
||||
assert state.state.isnumeric()
|
||||
assert state.attributes.get('unit_of_measurement') is None
|
||||
|
||||
def test_custom_setup(self, betamax_session):
|
||||
now = datetime(2016, 1, 5, 1, tzinfo=dt_util.UTC)
|
||||
|
||||
with patch('homeassistant.components.sensor.yr.requests.Session',
|
||||
return_value=betamax_session):
|
||||
assert sensor.setup(self.hass, {
|
||||
'sensor': {
|
||||
'platform': 'yr',
|
||||
'elevation': 0,
|
||||
'monitored_conditions': {
|
||||
'pressure',
|
||||
'windDirection',
|
||||
'humidity',
|
||||
'fog',
|
||||
'windSpeed'
|
||||
with patch('homeassistant.components.sensor.yr.dt_util.utcnow',
|
||||
return_value=now):
|
||||
assert sensor.setup(self.hass, {
|
||||
'sensor': {
|
||||
'platform': 'yr',
|
||||
'elevation': 0,
|
||||
'monitored_conditions': {
|
||||
'pressure',
|
||||
'windDirection',
|
||||
'humidity',
|
||||
'fog',
|
||||
'windSpeed'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
state = self.hass.states.get('sensor.yr_pressure')
|
||||
assert 'hPa', state.attributes.get('unit_of_measurement')
|
||||
assert 'hPa' == state.attributes.get('unit_of_measurement')
|
||||
assert '1025.1' == state.state
|
||||
|
||||
state = self.hass.states.get('sensor.yr_wind_direction')
|
||||
assert '°', state.attributes.get('unit_of_measurement')
|
||||
assert '°'== state.attributes.get('unit_of_measurement')
|
||||
assert '81.8' == state.state
|
||||
|
||||
state = self.hass.states.get('sensor.yr_humidity')
|
||||
assert '%', state.attributes.get('unit_of_measurement')
|
||||
assert '%' == state.attributes.get('unit_of_measurement')
|
||||
assert '79.6' == state.state
|
||||
|
||||
state = self.hass.states.get('sensor.yr_fog')
|
||||
assert '%', state.attributes.get('unit_of_measurement')
|
||||
assert '%' == state.attributes.get('unit_of_measurement')
|
||||
assert '0.0' == state.state
|
||||
|
||||
state = self.hass.states.get('sensor.yr_wind_speed')
|
||||
assert 'm/s', state.attributes.get('unit_of_measurement')
|
||||
assert '4.3' == state.state
|
||||
|
Loading…
x
Reference in New Issue
Block a user