Skip to content

Commit

Permalink
Fix Yandex transport after API change (home-assistant#32500)
Browse files Browse the repository at this point in the history
* Update Yandex transport after API change (home-assistant#32431)

* Update mocked response for test (home-assistant#32431)

* Codestyle fixes (home-assistant#32431)
  • Loading branch information
devbis authored Mar 7, 2020
1 parent ae2e6f9 commit 1f51038
Show file tree
Hide file tree
Showing 3 changed files with 1,631 additions and 1,315 deletions.
6 changes: 2 additions & 4 deletions homeassistant/components/yandex_transport/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def update(self):
try:
yandex_reply = self.requester.get_stop_info(self._stop_id)
data = yandex_reply["data"]
stop_metadata = data["properties"]["StopMetaData"]
except KeyError as key_error:
_LOGGER.warning(
"Exception KeyError was captured, missing key is %s. Yandex returned: %s",
Expand All @@ -74,9 +73,8 @@ def update(self):
)
self.requester.set_new_session()
data = self.requester.get_stop_info(self._stop_id)["data"]
stop_metadata = data["properties"]["StopMetaData"]
stop_name = data["properties"]["name"]
transport_list = stop_metadata["Transport"]
stop_name = data["name"]
transport_list = data["transports"]
for transport in transport_list:
route = transport["name"]
for thread in transport["threads"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def mock_requester():
}

FILTERED_ATTRS = {
"т36": ["16:10", "16:17", "16:26"],
"т47": ["16:09", "16:10"],
"м10": ["16:12", "16:20"],
"т36": ["18:25", "18:42", "18:46"],
"т47": ["18:35", "18:37", "18:40", "18:42"],
"м10": ["18:20", "18:27", "18:29", "18:41", "18:43"],
"stop_name": "7-й автобусный парк",
"attribution": "Data provided by maps.yandex.ru",
}

RESULT_STATE = dt_util.utc_from_timestamp(1570972183).isoformat(timespec="seconds")
RESULT_STATE = dt_util.utc_from_timestamp(1583421540).isoformat(timespec="seconds")


async def assert_setup_sensor(hass, config, count=1):
Expand Down
Loading

0 comments on commit 1f51038

Please sign in to comment.