Skip to content

Commit 9d0e56c

Browse files
authored
Merge pull request #246 from jwillemsen/jwi-codecovupdatecoord
Moved some test code to another method to increase coverage
2 parents cc6ec24 + 8de8ded commit 9d0e56c

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

tests/test_init.py

+18-15
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,21 @@ async def test_water_heater(
450450

451451
assert len(responses.calls) == 9
452452

453+
# In order to call update_entity we need to setup the HA core
454+
await async_setup_component(hass, "homeassistant", {})
455+
456+
# Try to call update_entity service to trigger an update but because we just did patches
457+
# this is a noop
458+
await hass.services.async_call(
459+
HA_DOMAIN,
460+
SERVICE_UPDATE_ENTITY,
461+
{ATTR_ENTITY_ID: "water_heater.altherma"},
462+
blocking=True,
463+
)
464+
await hass.async_block_till_done()
465+
466+
assert len(responses.calls) == 9
467+
453468

454469
@responses.activate
455470
async def test_climate(
@@ -933,14 +948,14 @@ async def test_climate(
933948
assert len(responses.calls) == 32
934949
assert hass.states.get("climate.werkkamer_room_temperature").state == HVACMode.DRY
935950

951+
# In order to call update_entity we need to setup the HA core
952+
await async_setup_component(hass, "homeassistant", {})
953+
936954
# We patch the scan_ignore method to zero so that the coordinator will pull again
937955
with patch(
938956
"custom_components.daikin_onecta.OnectaDataUpdateCoordinator.scan_ignore",
939957
return_value=0,
940958
):
941-
# In order to call update_entity we need to setup the HA core
942-
await async_setup_component(hass, "homeassistant", {})
943-
944959
with responses.RequestsMock() as rsps:
945960
rsps.get(DAIKIN_API_URL + "/v1/gateway-devices", status=200, json=load_fixture_json("altherma"))
946961
# Call update_entity service to trigger an update
@@ -954,15 +969,3 @@ async def test_climate(
954969

955970
assert len(rsps.calls) == 1
956971
assert rsps.calls[0].request.url == DAIKIN_API_URL + "/v1/gateway-devices"
957-
958-
# Try to call update_entity service to trigger an update but because we just did this it
959-
# is a noop
960-
await hass.services.async_call(
961-
HA_DOMAIN,
962-
SERVICE_UPDATE_ENTITY,
963-
{ATTR_ENTITY_ID: "climate.werkkamer_room_temperature"},
964-
blocking=True,
965-
)
966-
await hass.async_block_till_done()
967-
968-
assert len(rsps.calls) == 1

0 commit comments

Comments
 (0)