From fe316f2233f112d84dbeadf873b8d78d62a43fe8 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 5 Oct 2023 16:11:15 -0400 Subject: [PATCH] Fix key error in config flow when duplicate stop names exist (#101491) --- homeassistant/components/nextbus/config_flow.py | 2 +- tests/components/nextbus/conftest.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/nextbus/config_flow.py b/homeassistant/components/nextbus/config_flow.py index d7149bcc9f4..000dd86eb52 100644 --- a/homeassistant/components/nextbus/config_flow.py +++ b/homeassistant/components/nextbus/config_flow.py @@ -58,7 +58,7 @@ def _get_stop_tags( # Append directions for stops with shared titles for tag, title in tags.items(): if title_counts[title] > 1: - tags[tag] = f"{title} ({stop_directions[tag]})" + tags[tag] = f"{title} ({stop_directions.get(tag, tag)})" return tags diff --git a/tests/components/nextbus/conftest.py b/tests/components/nextbus/conftest.py index a38f3fd850e..0940118c13a 100644 --- a/tests/components/nextbus/conftest.py +++ b/tests/components/nextbus/conftest.py @@ -19,6 +19,8 @@ def mock_nextbus_lists(mock_nextbus: MagicMock) -> MagicMock: "stop": [ {"tag": "5650", "title": "Market St & 7th St"}, {"tag": "5651", "title": "Market St & 7th St"}, + # Error case test. Duplicate title with no unique direction + {"tag": "5652", "title": "Market St & 7th St"}, ], "direction": [ {