mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Empty response returns empty list in Nord Pool (#145514)
This commit is contained in:
parent
e22fbe553b
commit
970359c6a0
@ -97,11 +97,8 @@ def async_setup_services(hass: HomeAssistant) -> None:
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="authentication_error",
|
||||
) from error
|
||||
except NordPoolEmptyResponseError as error:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="empty_response",
|
||||
) from error
|
||||
except NordPoolEmptyResponseError:
|
||||
return {area: [] for area in areas}
|
||||
except NordPoolError as error:
|
||||
raise ServiceValidationError(
|
||||
translation_domain=DOMAIN,
|
||||
|
@ -129,9 +129,6 @@
|
||||
"authentication_error": {
|
||||
"message": "There was an authentication error as you tried to retrieve data too far in the past."
|
||||
},
|
||||
"empty_response": {
|
||||
"message": "Nord Pool has not posted market prices for the provided date."
|
||||
},
|
||||
"connection_error": {
|
||||
"message": "There was a connection error connecting to the API. Try again later."
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
# serializer version: 1
|
||||
# name: test_empty_response_returns_empty_list
|
||||
dict({
|
||||
'SE3': list([
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
# name: test_service_call
|
||||
dict({
|
||||
'SE3': list([
|
||||
|
@ -74,7 +74,6 @@ async def test_service_call(
|
||||
("error", "key"),
|
||||
[
|
||||
(NordPoolAuthenticationError, "authentication_error"),
|
||||
(NordPoolEmptyResponseError, "empty_response"),
|
||||
(NordPoolError, "connection_error"),
|
||||
],
|
||||
)
|
||||
@ -106,6 +105,33 @@ async def test_service_call_failures(
|
||||
assert err.value.translation_key == key
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2024-11-05T18:00:00+00:00")
|
||||
async def test_empty_response_returns_empty_list(
|
||||
hass: HomeAssistant,
|
||||
load_int: MockConfigEntry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test get_prices_for_date service call return empty list for empty response."""
|
||||
service_data = TEST_SERVICE_DATA.copy()
|
||||
service_data[ATTR_CONFIG_ENTRY] = load_int.entry_id
|
||||
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.nordpool.coordinator.NordPoolClient.async_get_delivery_period",
|
||||
side_effect=NordPoolEmptyResponseError,
|
||||
),
|
||||
):
|
||||
response = await hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_GET_PRICES_FOR_DATE,
|
||||
service_data,
|
||||
blocking=True,
|
||||
return_response=True,
|
||||
)
|
||||
|
||||
assert response == snapshot
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2024-11-05T18:00:00+00:00")
|
||||
async def test_service_call_config_entry_bad_state(
|
||||
hass: HomeAssistant,
|
||||
|
Loading…
x
Reference in New Issue
Block a user