Speedtestdotnet - use server name to generate server list (#39775)
parent
903afb62d0
commit
11319ac479
|
@ -143,9 +143,12 @@ class SpeedTestDataCoordinator(DataUpdateCoordinator):
|
|||
|
||||
self.servers[DEFAULT_SERVER] = {}
|
||||
for server in sorted(
|
||||
server_list.values(), key=lambda server: server[0]["country"]
|
||||
server_list.values(),
|
||||
key=lambda server: server[0]["country"] + server[0]["sponsor"],
|
||||
):
|
||||
self.servers[f"{server[0]['country']} - {server[0]['sponsor']}"] = server[0]
|
||||
self.servers[
|
||||
f"{server[0]['country']} - {server[0]['sponsor']} - {server[0]['name']}"
|
||||
] = server[0]
|
||||
|
||||
def update_data(self):
|
||||
"""Get the latest data from speedtest.net."""
|
||||
|
|
|
@ -9,7 +9,7 @@ MOCK_SERVERS = {
|
|||
"name": "Server1",
|
||||
"country": "Country1",
|
||||
"cc": "LL1",
|
||||
"sponsor": "Server1",
|
||||
"sponsor": "Sponsor1",
|
||||
"id": "1",
|
||||
"host": "server1:8080",
|
||||
"d": 1,
|
||||
|
@ -23,7 +23,7 @@ MOCK_SERVERS = {
|
|||
"name": "Server2",
|
||||
"country": "Country2",
|
||||
"cc": "LL2",
|
||||
"sponsor": "server2",
|
||||
"sponsor": "Sponsor2",
|
||||
"id": "2",
|
||||
"host": "server2:8080",
|
||||
"d": 2,
|
||||
|
|
|
@ -108,7 +108,7 @@ async def test_options(hass):
|
|||
result = await hass.config_entries.options.async_configure(
|
||||
result["flow_id"],
|
||||
user_input={
|
||||
CONF_SERVER_NAME: "Country1 - Server1",
|
||||
CONF_SERVER_NAME: "Country1 - Sponsor1 - Server1",
|
||||
CONF_SCAN_INTERVAL: 30,
|
||||
CONF_MANUAL: False,
|
||||
},
|
||||
|
@ -116,7 +116,7 @@ async def test_options(hass):
|
|||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["data"] == {
|
||||
CONF_SERVER_NAME: "Country1 - Server1",
|
||||
CONF_SERVER_NAME: "Country1 - Sponsor1 - Server1",
|
||||
CONF_SERVER_ID: "1",
|
||||
CONF_SCAN_INTERVAL: 30,
|
||||
CONF_MANUAL: False,
|
||||
|
|
Loading…
Reference in New Issue