Adds London_air component (#9020)
* Adds London_air component * Fix lints * Reduce fixture * Fix config validate * Fix naming * fix tests
This commit is contained in:
parent
597f53ae30
commit
98370560e1
3 changed files with 309 additions and 0 deletions
41
tests/components/sensor/test_london_air.py
Normal file
41
tests/components/sensor/test_london_air.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
"""The tests for the tube_state platform."""
|
||||
import unittest
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.components.sensor.london_air import (
|
||||
CONF_LOCATIONS, URL)
|
||||
from homeassistant.setup import setup_component
|
||||
from tests.common import load_fixture, get_test_home_assistant
|
||||
|
||||
VALID_CONFIG = {
|
||||
'platform': 'london_air',
|
||||
CONF_LOCATIONS: [
|
||||
'Merton',
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
class TestLondonAirSensor(unittest.TestCase):
|
||||
"""Test the tube_state platform."""
|
||||
|
||||
def setUp(self):
|
||||
"""Initialize values for this testcase class."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.config = VALID_CONFIG
|
||||
|
||||
def tearDown(self):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
@requests_mock.Mocker()
|
||||
def test_setup(self, mock_req):
|
||||
"""Test for operational tube_state sensor with proper attributes."""
|
||||
mock_req.get(URL, text=load_fixture('london_air.json'))
|
||||
self.assertTrue(
|
||||
setup_component(self.hass, 'sensor', {'sensor': self.config}))
|
||||
|
||||
state = self.hass.states.get('sensor.merton')
|
||||
assert state.state == 'Low'
|
||||
assert state.attributes.get('updated') == '2017-08-03 03:00:00'
|
||||
assert state.attributes.get('sites') == 2
|
||||
assert state.attributes.get('data')[0]['site_code'] == 'ME2'
|
Loading…
Add table
Add a link
Reference in a new issue