mirror of
https://github.com/home-assistant/core.git
synced 2026-09-28 02:18:10 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user