Nextbus upcoming sort as integer (#61416)

This commit is contained in:
Ian 2021-12-17 00:39:55 -08:00 committed by GitHub
parent 67255d4b52
commit a6cfbd4072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -218,7 +218,7 @@ class NextBusDepartureSensor(SensorEntity):
# Generate list of upcoming times
self._attributes["upcoming"] = ", ".join(
sorted(p["minutes"] for p in predictions)
sorted((p["minutes"] for p in predictions), key=int)
)
latest_prediction = maybe_first(predictions)

View file

@ -40,6 +40,7 @@ BASIC_RESULTS = {
{"minutes": "1", "epochTime": "1553807371000"},
{"minutes": "2", "epochTime": "1553807372000"},
{"minutes": "3", "epochTime": "1553807373000"},
{"minutes": "10", "epochTime": "1553807380000"},
],
},
}
@ -128,7 +129,7 @@ async def test_verify_valid_state(
assert state.attributes["route"] == VALID_ROUTE_TITLE
assert state.attributes["stop"] == VALID_STOP_TITLE
assert state.attributes["direction"] == "Outbound"
assert state.attributes["upcoming"] == "1, 2, 3"
assert state.attributes["upcoming"] == "1, 2, 3, 10"
async def test_message_dict(