Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use direct service calls in flux tests instead of switch common #40704

Merged
merged 1 commit into from Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
129 changes: 96 additions & 33 deletions tests/components/flux/test_switch.py
Expand Up @@ -20,7 +20,6 @@
async_mock_service,
mock_restore_cache,
)
from tests.components.switch import common


async def test_valid_config(hass):
Expand Down Expand Up @@ -224,8 +223,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -333,8 +340,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -389,8 +400,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -444,8 +459,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -501,8 +520,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -559,8 +582,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -621,8 +648,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -683,8 +714,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -744,8 +779,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -805,8 +844,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -863,8 +906,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -920,8 +967,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -993,8 +1044,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -1053,8 +1108,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down Expand Up @@ -1106,8 +1165,12 @@ def event_date(hass, event, now=None):
)
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]
Expand Down