Improve string formatting v7 (#33705)
This commit is contained in:
1 parent
15f41c84f9
commit
67c3a4c970
7 files changed
+164
-164
No files matched your search
@@ -51,7 +51,7 @@ async def test_default_setup(hass, monkeypatch):
|
||||
assert create.call_args_list[0][1]["ignore"]
|
||||
|
||||
# test default state of cover loaded from config
|
||||
cover_initial = hass.states.get(DOMAIN + ".test")
|
||||
cover_initial = hass.states.get(f"{DOMAIN}.test")
|
||||
assert cover_initial.state == STATE_CLOSED
|
||||
assert cover_initial.attributes["assumed_state"]
|
||||
|
||||
@@ -62,7 +62,7 @@ async def test_default_setup(hass, monkeypatch):
|
||||
event_callback({"id": "protocol_0_0", "command": "up"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
cover_after_first_command = hass.states.get(DOMAIN + ".test")
|
||||
cover_after_first_command = hass.states.get(f"{DOMAIN}.test")
|
||||
assert cover_after_first_command.state == STATE_OPEN
|
||||
# not sure why, but cover have always assumed_state=true
|
||||
assert cover_after_first_command.attributes.get("assumed_state")
|
||||
@@ -71,46 +71,46 @@ async def test_default_setup(hass, monkeypatch):
|
||||
event_callback({"id": "protocol_0_0", "command": "down"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_CLOSED
|
||||
|
||||
# should respond to group command
|
||||
event_callback({"id": "protocol_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
cover_after_first_command = hass.states.get(DOMAIN + ".test")
|
||||
cover_after_first_command = hass.states.get(f"{DOMAIN}.test")
|
||||
assert cover_after_first_command.state == STATE_OPEN
|
||||
|
||||
# should respond to group command
|
||||
event_callback({"id": "protocol_0_0", "command": "alloff"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_CLOSED
|
||||
|
||||
# test following aliases
|
||||
# mock incoming command event for this device alias
|
||||
event_callback({"id": "test_alias_0_0", "command": "up"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_OPEN
|
||||
|
||||
# test changing state from HA propagates to RFLink
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_CLOSED
|
||||
assert protocol.send_command_ack.call_args_list[0][0][0] == "protocol_0_0"
|
||||
assert protocol.send_command_ack.call_args_list[0][0][1] == "DOWN"
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_OPEN
|
||||
assert protocol.send_command_ack.call_args_list[1][0][1] == "UP"
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ async def test_firing_bus_event(hass, monkeypatch):
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert calls[0].data == {"state": "down", "entity_id": DOMAIN + ".test"}
|
||||
assert calls[0].data == {"state": "down", "entity_id": f"{DOMAIN}.test"}
|
||||
|
||||
|
||||
async def test_signal_repetitions(hass, monkeypatch):
|
||||
@@ -169,7 +169,7 @@ async def test_signal_repetitions(hass, monkeypatch):
|
||||
# test if signal repetition is performed according to configuration
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -181,7 +181,7 @@ async def test_signal_repetitions(hass, monkeypatch):
|
||||
# test if default apply to configured devices
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: DOMAIN + ".test1"}
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.test1"}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -209,12 +209,12 @@ async def test_signal_repetitions_alternation(hass, monkeypatch):
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: DOMAIN + ".test1"}
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.test1"}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -241,13 +241,13 @@ async def test_signal_repetitions_cancelling(hass, monkeypatch):
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -274,19 +274,19 @@ async def test_group_alias(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_CLOSED
|
||||
|
||||
# test sending group command to group alias
|
||||
event_callback({"id": "test_group_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_OPEN
|
||||
|
||||
# test sending group command to group alias
|
||||
event_callback({"id": "test_group_0_0", "command": "down"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_OPEN
|
||||
|
||||
|
||||
async def test_nogroup_alias(hass, monkeypatch):
|
||||
@@ -307,19 +307,19 @@ async def test_nogroup_alias(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_CLOSED
|
||||
|
||||
# test sending group command to nogroup alias
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
# should not affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_CLOSED
|
||||
|
||||
# test sending group command to nogroup alias
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "up"})
|
||||
await hass.async_block_till_done()
|
||||
# should affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_OPEN
|
||||
|
||||
|
||||
async def test_nogroup_device_id(hass, monkeypatch):
|
||||
@@ -335,19 +335,19 @@ async def test_nogroup_device_id(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_CLOSED
|
||||
|
||||
# test sending group command to nogroup
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
# should not affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_CLOSED
|
||||
|
||||
# test sending group command to nogroup
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "up"})
|
||||
await hass.async_block_till_done()
|
||||
# should affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == STATE_OPEN
|
||||
|
||||
|
||||
async def test_restore_state(hass, monkeypatch):
|
||||
@@ -366,7 +366,7 @@ async def test_restore_state(hass, monkeypatch):
|
||||
}
|
||||
|
||||
mock_restore_cache(
|
||||
hass, (State(DOMAIN + ".c1", STATE_OPEN), State(DOMAIN + ".c2", STATE_CLOSED))
|
||||
hass, (State(f"{DOMAIN}.c1", STATE_OPEN), State(f"{DOMAIN}.c2", STATE_CLOSED))
|
||||
)
|
||||
|
||||
hass.state = CoreState.starting
|
||||
@@ -374,20 +374,20 @@ async def test_restore_state(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
_, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
state = hass.states.get(DOMAIN + ".c1")
|
||||
state = hass.states.get(f"{DOMAIN}.c1")
|
||||
assert state
|
||||
assert state.state == STATE_OPEN
|
||||
|
||||
state = hass.states.get(DOMAIN + ".c2")
|
||||
state = hass.states.get(f"{DOMAIN}.c2")
|
||||
assert state
|
||||
assert state.state == STATE_CLOSED
|
||||
|
||||
state = hass.states.get(DOMAIN + ".c3")
|
||||
state = hass.states.get(f"{DOMAIN}.c3")
|
||||
assert state
|
||||
assert state.state == STATE_CLOSED
|
||||
|
||||
# not cached cover must default values
|
||||
state = hass.states.get(DOMAIN + ".c4")
|
||||
state = hass.states.get(f"{DOMAIN}.c4")
|
||||
assert state
|
||||
assert state.state == STATE_CLOSED
|
||||
assert state.attributes["assumed_state"]
|
||||
@@ -431,7 +431,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
)
|
||||
|
||||
# test default state of cover loaded from config
|
||||
standard_cover = hass.states.get(DOMAIN + ".nonkaku_type_standard")
|
||||
standard_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_standard")
|
||||
assert standard_cover.state == STATE_CLOSED
|
||||
assert standard_cover.attributes["assumed_state"]
|
||||
|
||||
@@ -439,7 +439,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
event_callback({"id": "nonkaku_device_1", "command": "up"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
standard_cover = hass.states.get(DOMAIN + ".nonkaku_type_standard")
|
||||
standard_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_standard")
|
||||
assert standard_cover.state == STATE_OPEN
|
||||
assert standard_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -447,7 +447,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
event_callback({"id": "nonkaku_device_2", "command": "up"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
standard_cover = hass.states.get(DOMAIN + ".nonkaku_type_none")
|
||||
standard_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_none")
|
||||
assert standard_cover.state == STATE_OPEN
|
||||
assert standard_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -456,7 +456,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".nonkaku_type_inverted")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_inverted")
|
||||
assert inverted_cover.state == STATE_OPEN
|
||||
assert inverted_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -465,7 +465,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_standard")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_standard")
|
||||
assert inverted_cover.state == STATE_OPEN
|
||||
assert inverted_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -474,7 +474,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_none")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_none")
|
||||
assert inverted_cover.state == STATE_OPEN
|
||||
assert inverted_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -483,7 +483,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_inverted")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_inverted")
|
||||
assert inverted_cover.state == STATE_OPEN
|
||||
assert inverted_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -492,7 +492,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
standard_cover = hass.states.get(DOMAIN + ".nonkaku_type_standard")
|
||||
standard_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_standard")
|
||||
assert standard_cover.state == STATE_CLOSED
|
||||
assert standard_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -501,7 +501,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
standard_cover = hass.states.get(DOMAIN + ".nonkaku_type_none")
|
||||
standard_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_none")
|
||||
assert standard_cover.state == STATE_CLOSED
|
||||
assert standard_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -510,7 +510,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".nonkaku_type_inverted")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_inverted")
|
||||
assert inverted_cover.state == STATE_CLOSED
|
||||
assert inverted_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -519,7 +519,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_standard")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_standard")
|
||||
assert inverted_cover.state == STATE_CLOSED
|
||||
assert inverted_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -528,7 +528,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_none")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_none")
|
||||
assert inverted_cover.state == STATE_CLOSED
|
||||
assert inverted_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -537,7 +537,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_inverted")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_inverted")
|
||||
assert inverted_cover.state == STATE_CLOSED
|
||||
assert inverted_cover.attributes.get("assumed_state")
|
||||
|
||||
@@ -549,7 +549,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".nonkaku_type_inverted")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_inverted")
|
||||
assert inverted_cover.state == STATE_CLOSED
|
||||
|
||||
# should respond to group command
|
||||
@@ -557,7 +557,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".nonkaku_type_inverted")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.nonkaku_type_inverted")
|
||||
assert inverted_cover.state == STATE_OPEN
|
||||
|
||||
# should respond to group command
|
||||
@@ -565,7 +565,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_standard")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_standard")
|
||||
assert inverted_cover.state == STATE_CLOSED
|
||||
|
||||
# should respond to group command
|
||||
@@ -573,7 +573,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_standard")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_standard")
|
||||
assert inverted_cover.state == STATE_OPEN
|
||||
|
||||
# should respond to group command
|
||||
@@ -581,7 +581,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_none")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_none")
|
||||
assert inverted_cover.state == STATE_CLOSED
|
||||
|
||||
# should respond to group command
|
||||
@@ -589,7 +589,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_none")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_none")
|
||||
assert inverted_cover.state == STATE_OPEN
|
||||
|
||||
# should respond to group command
|
||||
@@ -597,7 +597,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_inverted")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_inverted")
|
||||
assert inverted_cover.state == STATE_CLOSED
|
||||
|
||||
# should respond to group command
|
||||
@@ -605,7 +605,7 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
inverted_cover = hass.states.get(DOMAIN + ".newkaku_type_inverted")
|
||||
inverted_cover = hass.states.get(f"{DOMAIN}.newkaku_type_inverted")
|
||||
assert inverted_cover.state == STATE_OPEN
|
||||
|
||||
# Sending the close command from HA should result
|
||||
@@ -615,13 +615,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".nonkaku_type_standard"},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.nonkaku_type_standard"},
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".nonkaku_type_standard").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.nonkaku_type_standard").state == STATE_CLOSED
|
||||
assert protocol.send_command_ack.call_args_list[0][0][0] == "nonkaku_device_1"
|
||||
assert protocol.send_command_ack.call_args_list[0][0][1] == "DOWN"
|
||||
|
||||
@@ -632,13 +632,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_OPEN_COVER,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".nonkaku_type_standard"},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.nonkaku_type_standard"},
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".nonkaku_type_standard").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.nonkaku_type_standard").state == STATE_OPEN
|
||||
assert protocol.send_command_ack.call_args_list[1][0][0] == "nonkaku_device_1"
|
||||
assert protocol.send_command_ack.call_args_list[1][0][1] == "UP"
|
||||
|
||||
@@ -647,13 +647,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
# that has its type not specified.
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: DOMAIN + ".nonkaku_type_none"}
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.nonkaku_type_none"}
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".nonkaku_type_none").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.nonkaku_type_none").state == STATE_CLOSED
|
||||
assert protocol.send_command_ack.call_args_list[2][0][0] == "nonkaku_device_2"
|
||||
assert protocol.send_command_ack.call_args_list[2][0][1] == "DOWN"
|
||||
|
||||
@@ -662,13 +662,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
# that has its type not specified.
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: DOMAIN + ".nonkaku_type_none"}
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.nonkaku_type_none"}
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".nonkaku_type_none").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.nonkaku_type_none").state == STATE_OPEN
|
||||
assert protocol.send_command_ack.call_args_list[3][0][0] == "nonkaku_device_2"
|
||||
assert protocol.send_command_ack.call_args_list[3][0][1] == "UP"
|
||||
|
||||
@@ -679,13 +679,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".nonkaku_type_inverted"},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.nonkaku_type_inverted"},
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".nonkaku_type_inverted").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.nonkaku_type_inverted").state == STATE_CLOSED
|
||||
assert protocol.send_command_ack.call_args_list[4][0][0] == "nonkaku_device_3"
|
||||
assert protocol.send_command_ack.call_args_list[4][0][1] == "UP"
|
||||
|
||||
@@ -696,13 +696,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_OPEN_COVER,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".nonkaku_type_inverted"},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.nonkaku_type_inverted"},
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".nonkaku_type_inverted").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.nonkaku_type_inverted").state == STATE_OPEN
|
||||
assert protocol.send_command_ack.call_args_list[5][0][0] == "nonkaku_device_3"
|
||||
assert protocol.send_command_ack.call_args_list[5][0][1] == "DOWN"
|
||||
|
||||
@@ -713,13 +713,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".newkaku_type_standard"},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.newkaku_type_standard"},
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".newkaku_type_standard").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.newkaku_type_standard").state == STATE_CLOSED
|
||||
assert protocol.send_command_ack.call_args_list[6][0][0] == "newkaku_device_4"
|
||||
assert protocol.send_command_ack.call_args_list[6][0][1] == "DOWN"
|
||||
|
||||
@@ -730,13 +730,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_OPEN_COVER,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".newkaku_type_standard"},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.newkaku_type_standard"},
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".newkaku_type_standard").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.newkaku_type_standard").state == STATE_OPEN
|
||||
assert protocol.send_command_ack.call_args_list[7][0][0] == "newkaku_device_4"
|
||||
assert protocol.send_command_ack.call_args_list[7][0][1] == "UP"
|
||||
|
||||
@@ -745,13 +745,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
# that has its type not specified.
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: DOMAIN + ".newkaku_type_none"}
|
||||
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.newkaku_type_none"}
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".newkaku_type_none").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.newkaku_type_none").state == STATE_CLOSED
|
||||
assert protocol.send_command_ack.call_args_list[8][0][0] == "newkaku_device_5"
|
||||
assert protocol.send_command_ack.call_args_list[8][0][1] == "UP"
|
||||
|
||||
@@ -760,13 +760,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
# that has its type not specified.
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: DOMAIN + ".newkaku_type_none"}
|
||||
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: f"{DOMAIN}.newkaku_type_none"}
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".newkaku_type_none").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.newkaku_type_none").state == STATE_OPEN
|
||||
assert protocol.send_command_ack.call_args_list[9][0][0] == "newkaku_device_5"
|
||||
assert protocol.send_command_ack.call_args_list[9][0][1] == "DOWN"
|
||||
|
||||
@@ -777,13 +777,13 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_CLOSE_COVER,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".newkaku_type_inverted"},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.newkaku_type_inverted"},
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".newkaku_type_inverted").state == STATE_CLOSED
|
||||
assert hass.states.get(f"{DOMAIN}.newkaku_type_inverted").state == STATE_CLOSED
|
||||
assert protocol.send_command_ack.call_args_list[10][0][0] == "newkaku_device_6"
|
||||
assert protocol.send_command_ack.call_args_list[10][0][1] == "UP"
|
||||
|
||||
@@ -794,12 +794,12 @@ async def test_inverted_cover(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_OPEN_COVER,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".newkaku_type_inverted"},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.newkaku_type_inverted"},
|
||||
)
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".newkaku_type_inverted").state == STATE_OPEN
|
||||
assert hass.states.get(f"{DOMAIN}.newkaku_type_inverted").state == STATE_OPEN
|
||||
assert protocol.send_command_ack.call_args_list[11][0][0] == "newkaku_device_6"
|
||||
assert protocol.send_command_ack.call_args_list[11][0][1] == "DOWN"
|
||||
@@ -315,7 +315,7 @@ async def test_race_condition(hass, monkeypatch):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# test state of new sensor
|
||||
new_sensor = hass.states.get(domain + ".test3")
|
||||
new_sensor = hass.states.get(f"{domain}.test3")
|
||||
assert new_sensor
|
||||
assert new_sensor.state == "off"
|
||||
|
||||
@@ -325,7 +325,7 @@ async def test_race_condition(hass, monkeypatch):
|
||||
assert tmp_entity not in hass.data[DATA_ENTITY_LOOKUP][EVENT_KEY_COMMAND]["test3"]
|
||||
|
||||
# test state of new sensor
|
||||
new_sensor = hass.states.get(domain + ".test3")
|
||||
new_sensor = hass.states.get(f"{domain}.test3")
|
||||
assert new_sensor
|
||||
assert new_sensor.state == "on"
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ async def test_default_setup(hass, monkeypatch):
|
||||
assert create.call_args_list[0][1]["ignore"]
|
||||
|
||||
# test default state of light loaded from config
|
||||
light_initial = hass.states.get(DOMAIN + ".test")
|
||||
light_initial = hass.states.get(f"{DOMAIN}.test")
|
||||
assert light_initial.state == "off"
|
||||
assert light_initial.attributes["assumed_state"]
|
||||
|
||||
@@ -58,7 +58,7 @@ async def test_default_setup(hass, monkeypatch):
|
||||
event_callback({"id": "protocol_0_0", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
light_after_first_command = hass.states.get(DOMAIN + ".test")
|
||||
light_after_first_command = hass.states.get(f"{DOMAIN}.test")
|
||||
assert light_after_first_command.state == "on"
|
||||
# also after receiving first command state not longer has to be assumed
|
||||
assert not light_after_first_command.attributes.get("assumed_state")
|
||||
@@ -67,52 +67,52 @@ async def test_default_setup(hass, monkeypatch):
|
||||
event_callback({"id": "protocol_0_0", "command": "off"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# should respond to group command
|
||||
event_callback({"id": "protocol_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
light_after_first_command = hass.states.get(DOMAIN + ".test")
|
||||
light_after_first_command = hass.states.get(f"{DOMAIN}.test")
|
||||
assert light_after_first_command.state == "on"
|
||||
|
||||
# should respond to group command
|
||||
event_callback({"id": "protocol_0_0", "command": "alloff"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test following aliases
|
||||
# mock incoming command event for this device alias
|
||||
event_callback({"id": "test_alias_0_0", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
# test event for new unconfigured sensor
|
||||
event_callback({"id": "protocol2_0_1", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".protocol2_0_1").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.protocol2_0_1").state == "on"
|
||||
|
||||
# test changing state from HA propagates to RFLink
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
assert protocol.send_command_ack.call_args_list[0][0][0] == "protocol_0_0"
|
||||
assert protocol.send_command_ack.call_args_list[0][0][1] == "off"
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
assert protocol.send_command_ack.call_args_list[1][0][1] == "on"
|
||||
|
||||
# protocols supporting dimming and on/off should create hybrid light entity
|
||||
@@ -120,7 +120,7 @@ async def test_default_setup(hass, monkeypatch):
|
||||
await hass.async_block_till_done()
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DOMAIN + ".newkaku_0_1"}
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: f"{DOMAIN}.newkaku_0_1"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
@@ -135,7 +135,7 @@ async def test_default_setup(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".newkaku_0_1", ATTR_BRIGHTNESS: 128},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.newkaku_0_1", ATTR_BRIGHTNESS: 128},
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
@@ -146,7 +146,7 @@ async def test_default_setup(hass, monkeypatch):
|
||||
hass.services.async_call(
|
||||
DOMAIN,
|
||||
SERVICE_TURN_ON,
|
||||
{ATTR_ENTITY_ID: DOMAIN + ".dim_test", ATTR_BRIGHTNESS: 128},
|
||||
{ATTR_ENTITY_ID: f"{DOMAIN}.dim_test", ATTR_BRIGHTNESS: 128},
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
@@ -186,7 +186,7 @@ async def test_firing_bus_event(hass, monkeypatch):
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert calls[0].data == {"state": "off", "entity_id": DOMAIN + ".test"}
|
||||
assert calls[0].data == {"state": "off", "entity_id": f"{DOMAIN}.test"}
|
||||
|
||||
|
||||
async def test_signal_repetitions(hass, monkeypatch):
|
||||
@@ -212,7 +212,7 @@ async def test_signal_repetitions(hass, monkeypatch):
|
||||
# test if signal repetition is performed according to configuration
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -224,7 +224,7 @@ async def test_signal_repetitions(hass, monkeypatch):
|
||||
# test if default apply to configured devices
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".test1"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.test1"}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -241,7 +241,7 @@ async def test_signal_repetitions(hass, monkeypatch):
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".protocol_0_2"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.protocol_0_2"}
|
||||
)
|
||||
)
|
||||
|
||||
@@ -268,10 +268,10 @@ async def test_signal_repetitions_alternation(hass, monkeypatch):
|
||||
_, _, protocol, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".test1"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.test1"}
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
@@ -296,11 +296,11 @@ async def test_signal_repetitions_cancelling(hass, monkeypatch):
|
||||
_, _, protocol, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
|
||||
await hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DOMAIN + ".test"}, blocking=True
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}, blocking=True
|
||||
)
|
||||
|
||||
assert [call[0][1] for call in protocol.send_command_ack.call_args_list] == [
|
||||
@@ -325,39 +325,39 @@ async def test_type_toggle(hass, monkeypatch):
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
# default value = 'off'
|
||||
assert hass.states.get(DOMAIN + ".toggle_test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.toggle_test").state == "off"
|
||||
|
||||
# test sending 'on' command, must set state = 'on'
|
||||
event_callback({"id": "toggle_0_0", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".toggle_test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.toggle_test").state == "on"
|
||||
|
||||
# test sending 'on' command again, must set state = 'off'
|
||||
event_callback({"id": "toggle_0_0", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".toggle_test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.toggle_test").state == "off"
|
||||
|
||||
# test async_turn_off, must set state = 'on' ('off' + toggle)
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".toggle_test"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.toggle_test"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".toggle_test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.toggle_test").state == "on"
|
||||
|
||||
# test async_turn_on, must set state = 'off' (yes, sounds crazy)
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DOMAIN + ".toggle_test"}
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: f"{DOMAIN}.toggle_test"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".toggle_test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.toggle_test").state == "off"
|
||||
|
||||
|
||||
async def test_group_alias(hass, monkeypatch):
|
||||
@@ -375,19 +375,19 @@ async def test_group_alias(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to group alias
|
||||
event_callback({"id": "test_group_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
# test sending group command to group alias
|
||||
event_callback({"id": "test_group_0_0", "command": "off"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
|
||||
async def test_nogroup_alias(hass, monkeypatch):
|
||||
@@ -408,19 +408,19 @@ async def test_nogroup_alias(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to nogroup alias
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
# should not affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to nogroup alias
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
# should affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
|
||||
async def test_nogroup_device_id(hass, monkeypatch):
|
||||
@@ -436,19 +436,19 @@ async def test_nogroup_device_id(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to nogroup
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
# should not affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to nogroup
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
# should affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
|
||||
async def test_disable_automatic_add(hass, monkeypatch):
|
||||
@@ -466,7 +466,7 @@ async def test_disable_automatic_add(hass, monkeypatch):
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# make sure new device is not added
|
||||
assert not hass.states.get(DOMAIN + ".protocol_0_0")
|
||||
assert not hass.states.get(f"{DOMAIN}.protocol_0_0")
|
||||
|
||||
|
||||
async def test_restore_state(hass, monkeypatch):
|
||||
@@ -488,10 +488,10 @@ async def test_restore_state(hass, monkeypatch):
|
||||
mock_restore_cache(
|
||||
hass,
|
||||
(
|
||||
State(DOMAIN + ".l1", STATE_ON, {ATTR_BRIGHTNESS: "123"}),
|
||||
State(DOMAIN + ".l2", STATE_ON, {ATTR_BRIGHTNESS: "321"}),
|
||||
State(DOMAIN + ".l3", STATE_OFF),
|
||||
State(DOMAIN + ".l5", STATE_ON, {ATTR_BRIGHTNESS: "222"}),
|
||||
State(f"{DOMAIN}.l1", STATE_ON, {ATTR_BRIGHTNESS: "123"}),
|
||||
State(f"{DOMAIN}.l2", STATE_ON, {ATTR_BRIGHTNESS: "321"}),
|
||||
State(f"{DOMAIN}.l3", STATE_OFF),
|
||||
State(f"{DOMAIN}.l5", STATE_ON, {ATTR_BRIGHTNESS: "222"}),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -501,31 +501,31 @@ async def test_restore_state(hass, monkeypatch):
|
||||
_, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
# hybrid light must restore brightness
|
||||
state = hass.states.get(DOMAIN + ".l1")
|
||||
state = hass.states.get(f"{DOMAIN}.l1")
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 123
|
||||
|
||||
# normal light do NOT must restore brightness
|
||||
state = hass.states.get(DOMAIN + ".l2")
|
||||
state = hass.states.get(f"{DOMAIN}.l2")
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
assert not state.attributes.get(ATTR_BRIGHTNESS)
|
||||
|
||||
# OFF state also restores (or not)
|
||||
state = hass.states.get(DOMAIN + ".l3")
|
||||
state = hass.states.get(f"{DOMAIN}.l3")
|
||||
assert state
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
# not cached light must default values
|
||||
state = hass.states.get(DOMAIN + ".l4")
|
||||
state = hass.states.get(f"{DOMAIN}.l4")
|
||||
assert state
|
||||
assert state.state == STATE_OFF
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 255
|
||||
assert state.attributes["assumed_state"]
|
||||
|
||||
# test coverage for dimmable light
|
||||
state = hass.states.get(DOMAIN + ".l5")
|
||||
state = hass.states.get(f"{DOMAIN}.l5")
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
assert state.attributes[ATTR_BRIGHTNESS] == 222
|
||||
@@ -78,21 +78,21 @@ async def test_default_setup(hass, monkeypatch):
|
||||
# test changing state from HA propagates to Rflink
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
assert protocol.send_command_ack.call_args_list[0][0][0] == "protocol_0_0"
|
||||
assert protocol.send_command_ack.call_args_list[0][0][1] == "off"
|
||||
|
||||
hass.async_create_task(
|
||||
hass.services.async_call(
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: DOMAIN + ".test"}
|
||||
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: f"{DOMAIN}.test"}
|
||||
)
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
assert protocol.send_command_ack.call_args_list[1][0][1] == "on"
|
||||
|
||||
|
||||
@@ -111,19 +111,19 @@ async def test_group_alias(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to group alias
|
||||
event_callback({"id": "test_group_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
# test sending group command to group alias
|
||||
event_callback({"id": "test_group_0_0", "command": "off"})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
|
||||
async def test_nogroup_alias(hass, monkeypatch):
|
||||
@@ -144,19 +144,19 @@ async def test_nogroup_alias(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to nogroup alias
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
# should not affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to nogroup alias
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
# should affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
|
||||
async def test_nogroup_device_id(hass, monkeypatch):
|
||||
@@ -172,19 +172,19 @@ async def test_nogroup_device_id(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
event_callback, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to nogroup
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "allon"})
|
||||
await hass.async_block_till_done()
|
||||
# should not affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == "off"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "off"
|
||||
|
||||
# test sending group command to nogroup
|
||||
event_callback({"id": "test_nogroup_0_0", "command": "on"})
|
||||
await hass.async_block_till_done()
|
||||
# should affect state
|
||||
assert hass.states.get(DOMAIN + ".test").state == "on"
|
||||
assert hass.states.get(f"{DOMAIN}.test").state == "on"
|
||||
|
||||
|
||||
async def test_device_defaults(hass, monkeypatch):
|
||||
@@ -216,7 +216,7 @@ async def test_device_defaults(hass, monkeypatch):
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert calls[0].data == {"state": "off", "entity_id": DOMAIN + ".test"}
|
||||
assert calls[0].data == {"state": "off", "entity_id": f"{DOMAIN}.test"}
|
||||
|
||||
|
||||
async def test_not_firing_default(hass, monkeypatch):
|
||||
@@ -264,7 +264,7 @@ async def test_restore_state(hass, monkeypatch):
|
||||
}
|
||||
|
||||
mock_restore_cache(
|
||||
hass, (State(DOMAIN + ".s1", STATE_ON), State(DOMAIN + ".s2", STATE_OFF))
|
||||
hass, (State(f"{DOMAIN}.s1", STATE_ON), State(f"{DOMAIN}.s2", STATE_OFF))
|
||||
)
|
||||
|
||||
hass.state = CoreState.starting
|
||||
@@ -272,16 +272,16 @@ async def test_restore_state(hass, monkeypatch):
|
||||
# setup mocking rflink module
|
||||
_, _, _, _ = await mock_rflink(hass, config, DOMAIN, monkeypatch)
|
||||
|
||||
state = hass.states.get(DOMAIN + ".s1")
|
||||
state = hass.states.get(f"{DOMAIN}.s1")
|
||||
assert state
|
||||
assert state.state == STATE_ON
|
||||
|
||||
state = hass.states.get(DOMAIN + ".s2")
|
||||
state = hass.states.get(f"{DOMAIN}.s2")
|
||||
assert state
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
# not cached switch must default values
|
||||
state = hass.states.get(DOMAIN + ".s3")
|
||||
state = hass.states.get(f"{DOMAIN}.s3")
|
||||
assert state
|
||||
assert state.state == STATE_OFF
|
||||
assert state.attributes["assumed_state"]
|
||||
Reference in new issue
Block a user