Refactor Rest Switch with ManualTriggerEntity (#97403)

* Refactor Rest Switch with ManualTriggerEntity

* Fix test

* Fix 2

* review comments

* remove async_added_to_hass

* update on startup
This commit is contained in:
G Johansson
2023-08-15 11:43:47 +02:00
committed by GitHub
parent 87b7fc6c61
commit ed18c6a013
2 changed files with 42 additions and 20 deletions
+5 -5
View File
@@ -111,7 +111,7 @@ async def test_setup_minimum(hass: HomeAssistant) -> None:
with assert_setup_component(1, SWITCH_DOMAIN):
assert await async_setup_component(hass, SWITCH_DOMAIN, config)
await hass.async_block_till_done()
assert route.call_count == 1
assert route.call_count == 2
@respx.mock
@@ -129,7 +129,7 @@ async def test_setup_query_params(hass: HomeAssistant) -> None:
assert await async_setup_component(hass, SWITCH_DOMAIN, config)
await hass.async_block_till_done()
assert route.call_count == 1
assert route.call_count == 2
@respx.mock
@@ -148,7 +148,7 @@ async def test_setup(hass: HomeAssistant) -> None:
}
assert await async_setup_component(hass, SWITCH_DOMAIN, config)
await hass.async_block_till_done()
assert route.call_count == 1
assert route.call_count == 2
assert_setup_component(1, SWITCH_DOMAIN)
@@ -170,7 +170,7 @@ async def test_setup_with_state_resource(hass: HomeAssistant) -> None:
}
assert await async_setup_component(hass, SWITCH_DOMAIN, config)
await hass.async_block_till_done()
assert route.call_count == 1
assert route.call_count == 2
assert_setup_component(1, SWITCH_DOMAIN)
@@ -195,7 +195,7 @@ async def test_setup_with_templated_headers_params(hass: HomeAssistant) -> None:
}
assert await async_setup_component(hass, SWITCH_DOMAIN, config)
await hass.async_block_till_done()
assert route.call_count == 1
assert route.call_count == 2
last_call = route.calls[-1]
last_request: httpx.Request = last_call.request
assert last_request.headers.get("Accept") == CONTENT_TYPE_JSON