Use direct service calls in flux tests instead of switch common (#40704)
This commit is contained in:
parent
c6f3352cf8
commit
4cce724473
1 changed files with 96 additions and 33 deletions
|
@ -20,7 +20,6 @@ from tests.common import (
|
|||
async_mock_service,
|
||||
mock_restore_cache,
|
||||
)
|
||||
from tests.components.switch import common
|
||||
|
||||
|
||||
async def test_valid_config(hass):
|
||||
|
@ -224,8 +223,12 @@ async def test_flux_before_sunrise(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
await common.async_turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -278,8 +281,12 @@ async def test_flux_before_sunrise_known_location(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
await common.async_turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -333,8 +340,12 @@ async def test_flux_after_sunrise_before_sunset(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
await common.async_turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -389,8 +400,12 @@ async def test_flux_after_sunset_before_stop(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -444,8 +459,12 @@ async def test_flux_after_stop_before_sunrise(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -501,8 +520,12 @@ async def test_flux_with_custom_start_stop_times(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -559,8 +582,12 @@ async def test_flux_before_sunrise_stop_next_day(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -621,8 +648,12 @@ async def test_flux_after_sunrise_before_sunset_stop_next_day(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -683,8 +714,12 @@ async def test_flux_after_sunset_before_midnight_stop_next_day(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -744,8 +779,12 @@ async def test_flux_after_sunset_after_midnight_stop_next_day(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -805,8 +844,12 @@ async def test_flux_after_stop_before_sunrise_stop_next_day(
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -863,8 +906,12 @@ async def test_flux_with_custom_colortemps(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -920,8 +967,12 @@ async def test_flux_with_custom_brightness(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -993,8 +1044,12 @@ async def test_flux_with_multiple_lights(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -1053,8 +1108,12 @@ async def test_flux_with_mired(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
common.turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
@ -1106,8 +1165,12 @@ async def test_flux_with_rgb(hass, legacy_patchable_time):
|
|||
)
|
||||
await hass.async_block_till_done()
|
||||
turn_on_calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
await common.async_turn_on(hass, "switch.flux")
|
||||
await hass.async_block_till_done()
|
||||
await hass.services.async_call(
|
||||
switch.DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: "switch.flux"},
|
||||
blocking=True,
|
||||
)
|
||||
async_fire_time_changed(hass, test_time)
|
||||
await hass.async_block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
|
|
Loading…
Add table
Reference in a new issue