Fix london_underground issue (#19642)
* Update london_underground.py * Update test * Update london_underground.py * Update london_underground.py * Update london_underground.py * Fix lint * Use london-tube-status==0.2
This commit is contained in:
1 parent
4b541f4058
commit
ff80fc347b
5 files changed
+7
-545
No files matched your search
@@ -1,37 +0,0 @@
|
||||
"""The tests for the tube_state platform."""
|
||||
import unittest
|
||||
import requests_mock
|
||||
|
||||
from homeassistant.components.sensor.london_underground import CONF_LINE, URL
|
||||
from homeassistant.setup import setup_component
|
||||
from tests.common import load_fixture, get_test_home_assistant
|
||||
|
||||
VALID_CONFIG = {
|
||||
'platform': 'london_underground',
|
||||
CONF_LINE: [
|
||||
'London Overground',
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
class TestLondonTubeSensor(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_underground.json'))
|
||||
assert setup_component(self.hass, 'sensor', {'sensor': self.config})
|
||||
|
||||
state = self.hass.states.get('sensor.london_overground')
|
||||
assert state.state == 'Minor Delays'
|
||||
assert state.attributes.get('Description') == 'something'
|
||||
-465
@@ -1,465 +0,0 @@
|
||||
[
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "bakerloo",
|
||||
"name": "Bakerloo",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.703Z",
|
||||
"modified": "2017-06-28T11:43:10.703Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Bakerloo&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "central",
|
||||
"name": "Central",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.623Z",
|
||||
"modified": "2017-06-28T11:43:10.623Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Central&serviceTypes=Regular"
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Night",
|
||||
"uri": "/Line/Route?ids=Central&serviceTypes=Night"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "circle",
|
||||
"name": "Circle",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.733Z",
|
||||
"modified": "2017-06-28T11:43:10.733Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Circle&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "district",
|
||||
"name": "District",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.623Z",
|
||||
"modified": "2017-06-28T11:43:10.623Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=District&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "dlr",
|
||||
"name": "DLR",
|
||||
"modeName": "dlr",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.703Z",
|
||||
"modified": "2017-06-28T11:43:10.703Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=DLR&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "hammersmith-city",
|
||||
"name": "Hammersmith & City",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.67Z",
|
||||
"modified": "2017-06-28T11:43:10.67Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Hammersmith & City&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "jubilee",
|
||||
"name": "Jubilee",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.623Z",
|
||||
"modified": "2017-06-28T11:43:10.623Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Jubilee&serviceTypes=Regular"
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Night",
|
||||
"uri": "/Line/Route?ids=Jubilee&serviceTypes=Night"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "london-overground",
|
||||
"name": "London Overground",
|
||||
"modeName": "overground",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.607Z",
|
||||
"modified": "2017-06-28T11:43:10.607Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"lineId": "london-overground",
|
||||
"statusSeverity": 9,
|
||||
"statusSeverityDescription": "Minor Delays",
|
||||
"reason": "something",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.ValidityPeriod, Tfl.Api.Presentation.Entities",
|
||||
"fromDate": "2017-06-29T06:27:21Z",
|
||||
"toDate": "2017-06-30T01:29:00Z",
|
||||
"isNow": true
|
||||
}
|
||||
],
|
||||
"disruption": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Disruption, Tfl.Api.Presentation.Entities",
|
||||
"category": "RealTime",
|
||||
"categoryDescription": "RealTime",
|
||||
"description": "London Overground: Minor delays Richmond to Stratford and Willesden Junction to Clapham Junction while we fix a faulty train at Richmond, GOOD SERVICE all other routes. ",
|
||||
"affectedRoutes": [],
|
||||
"affectedStops": [],
|
||||
"closureText": "minorDelays"
|
||||
}
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=London Overground&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "metropolitan",
|
||||
"name": "Metropolitan",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.703Z",
|
||||
"modified": "2017-06-28T11:43:10.703Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Metropolitan&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "northern",
|
||||
"name": "Northern",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.67Z",
|
||||
"modified": "2017-06-28T11:43:10.67Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Northern&serviceTypes=Regular"
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Night",
|
||||
"uri": "/Line/Route?ids=Northern&serviceTypes=Night"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "piccadilly",
|
||||
"name": "Piccadilly",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.67Z",
|
||||
"modified": "2017-06-28T11:43:10.67Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Piccadilly&serviceTypes=Regular"
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Night",
|
||||
"uri": "/Line/Route?ids=Piccadilly&serviceTypes=Night"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "tfl-rail",
|
||||
"name": "TfL Rail",
|
||||
"modeName": "tflrail",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.657Z",
|
||||
"modified": "2017-06-28T11:43:10.657Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=TfL Rail&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "victoria",
|
||||
"name": "Victoria",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.607Z",
|
||||
"modified": "2017-06-28T11:43:10.607Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Victoria&serviceTypes=Regular"
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Night",
|
||||
"uri": "/Line/Route?ids=Victoria&serviceTypes=Night"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
},
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.Line, Tfl.Api.Presentation.Entities",
|
||||
"id": "waterloo-city",
|
||||
"name": "Waterloo & City",
|
||||
"modeName": "tube",
|
||||
"disruptions": [],
|
||||
"created": "2017-06-28T11:43:10.703Z",
|
||||
"modified": "2017-06-28T11:43:10.703Z",
|
||||
"lineStatuses": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineStatus, Tfl.Api.Presentation.Entities",
|
||||
"id": 0,
|
||||
"statusSeverity": 10,
|
||||
"statusSeverityDescription": "Good Service",
|
||||
"created": "0001-01-01T00:00:00",
|
||||
"validityPeriods": []
|
||||
}
|
||||
],
|
||||
"routeSections": [],
|
||||
"serviceTypes": [
|
||||
{
|
||||
"$type": "Tfl.Api.Presentation.Entities.LineServiceTypeInfo, Tfl.Api.Presentation.Entities",
|
||||
"name": "Regular",
|
||||
"uri": "/Line/Route?ids=Waterloo & City&serviceTypes=Regular"
|
||||
}
|
||||
],
|
||||
"crowding": {
|
||||
"$type": "Tfl.Api.Presentation.Entities.Crowding, Tfl.Api.Presentation.Entities"
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user