Skip to content

Commit 8241a5f

Browse files
authored
Merge pull request #363 from jwillemsen/jwi-exceptionahdn
Test error 400 back on turn off
2 parents 6f879b5 + 0acd562 commit 8241a5f

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

tests/test_init.py

+64
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,70 @@ async def test_water_heater(
572572

573573
assert len(responses.calls) == 9
574574

575+
responses.patch(
576+
DAIKIN_API_URL
577+
+ "/v1/gateway-devices/1ece521b-5401-4a42-acce-6f76fba246aa/management-points/domesticHotWaterTank/characteristics/onOffMode",
578+
status=429,
579+
headers={"X-RateLimit-Limit-minute": "0", "X-RateLimit-Limit-day": "0"},
580+
)
581+
582+
# Turn the tank off, this should fail and not work due to the daily limit
583+
try:
584+
await hass.services.async_call(
585+
WATER_HEATER_DOMAIN,
586+
SERVICE_TURN_OFF,
587+
{ATTR_ENTITY_ID: "water_heater.altherma"},
588+
blocking=True,
589+
)
590+
await hass.async_block_till_done()
591+
except Exception:
592+
assert len(responses.calls) == 10
593+
594+
assert len(responses.calls) == 10
595+
assert responses.calls[9].request.body == '{"value": "off"}'
596+
assert hass.states.get("water_heater.altherma").attributes["operation_mode"] == STATE_HEAT_PUMP
597+
598+
responses.patch(
599+
DAIKIN_API_URL
600+
+ "/v1/gateway-devices/1ece521b-5401-4a42-acce-6f76fba246aa/management-points/domesticHotWaterTank/characteristics/onOffMode",
601+
status=204,
602+
)
603+
604+
await hass.services.async_call(
605+
WATER_HEATER_DOMAIN,
606+
SERVICE_TURN_OFF,
607+
{ATTR_ENTITY_ID: "water_heater.altherma"},
608+
blocking=True,
609+
)
610+
await hass.async_block_till_done()
611+
612+
assert len(responses.calls) == 11
613+
assert responses.calls[10].request.body == '{"value": "off"}'
614+
assert hass.states.get("water_heater.altherma").attributes["operation_mode"] == STATE_OFF
615+
616+
responses.patch(
617+
DAIKIN_API_URL
618+
+ "/v1/gateway-devices/1ece521b-5401-4a42-acce-6f76fba246aa/management-points/domesticHotWaterTank/characteristics/onOffMode",
619+
status=429,
620+
headers={"X-RateLimit-Limit-minute": "0", "X-RateLimit-Limit-day": "0"},
621+
)
622+
623+
# Turn the tank on, this should fail and not work due to the daily limit
624+
try:
625+
await hass.services.async_call(
626+
WATER_HEATER_DOMAIN,
627+
SERVICE_TURN_ON,
628+
{ATTR_ENTITY_ID: "water_heater.altherma"},
629+
blocking=True,
630+
)
631+
await hass.async_block_till_done()
632+
except Exception:
633+
assert len(responses.calls) == 12
634+
635+
assert len(responses.calls) == 12
636+
assert responses.calls[11].request.body == '{"value": "on"}'
637+
assert hass.states.get("water_heater.altherma").attributes["operation_mode"] == STATE_OFF
638+
575639

576640
@responses.activate
577641
async def test_climate(

0 commit comments

Comments
 (0)