Rename MockToggleDevice to MockToggleEntity (#26644)

* Rename MockToggleDevice to MockToggleEntity

* Fix tests
This commit is contained in:
Erik Montnemery authored and GitHub committed 2019-09-15 09:50:17 +02:00
1 parent 57833f5b1e
commit 6a60ebdb30
10 files changed
+200 -198

No files matched your search

+55 -55
View File
@@ -82,10 +82,10 @@ async def test_flux_when_switch_is_off(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -113,7 +113,7 @@ async def test_flux_when_switch_is_off(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
}
},
)
@@ -131,10 +131,10 @@ async def test_flux_before_sunrise(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -162,7 +162,7 @@ async def test_flux_before_sunrise(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
}
},
)
@@ -184,10 +184,10 @@ async def test_flux_before_sunrise_known_location(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -210,7 +210,7 @@ async def test_flux_before_sunrise_known_location(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
# 'brightness': 255,
# 'disable_brightness_adjust': True,
# 'mode': 'rgb',
@@ -237,10 +237,10 @@ async def test_flux_after_sunrise_before_sunset(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -267,7 +267,7 @@ async def test_flux_after_sunrise_before_sunset(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
}
},
)
@@ -290,10 +290,10 @@ async def test_flux_after_sunset_before_stop(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -320,7 +320,7 @@ async def test_flux_after_sunset_before_stop(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"stop_time": "22:00",
}
},
@@ -344,10 +344,10 @@ async def test_flux_after_stop_before_sunrise(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -374,7 +374,7 @@ async def test_flux_after_stop_before_sunrise(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
}
},
)
@@ -397,10 +397,10 @@ async def test_flux_with_custom_start_stop_times(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -427,7 +427,7 @@ async def test_flux_with_custom_start_stop_times(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"start_time": "6:00",
"stop_time": "23:30",
}
@@ -454,10 +454,10 @@ async def test_flux_before_sunrise_stop_next_day(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -484,7 +484,7 @@ async def test_flux_before_sunrise_stop_next_day(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"stop_time": "01:00",
}
},
@@ -512,10 +512,10 @@ async def test_flux_after_sunrise_before_sunset_stop_next_day(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -542,7 +542,7 @@ async def test_flux_after_sunrise_before_sunset_stop_next_day(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"stop_time": "01:00",
}
},
@@ -570,10 +570,10 @@ async def test_flux_after_sunset_before_midnight_stop_next_day(hass, x):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -600,7 +600,7 @@ async def test_flux_after_sunset_before_midnight_stop_next_day(hass, x):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"stop_time": "01:00",
}
},
@@ -627,10 +627,10 @@ async def test_flux_after_sunset_after_midnight_stop_next_day(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -657,7 +657,7 @@ async def test_flux_after_sunset_after_midnight_stop_next_day(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"stop_time": "01:00",
}
},
@@ -684,10 +684,10 @@ async def test_flux_after_stop_before_sunrise_stop_next_day(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -714,7 +714,7 @@ async def test_flux_after_stop_before_sunrise_stop_next_day(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"stop_time": "01:00",
}
},
@@ -738,10 +738,10 @@ async def test_flux_with_custom_colortemps(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -768,7 +768,7 @@ async def test_flux_with_custom_colortemps(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"start_colortemp": "1000",
"stop_colortemp": "6000",
"stop_time": "22:00",
@@ -794,10 +794,10 @@ async def test_flux_with_custom_brightness(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -824,7 +824,7 @@ async def test_flux_with_custom_brightness(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"brightness": 255,
"stop_time": "22:00",
}
@@ -848,23 +848,23 @@ async def test_flux_with_multiple_lights(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1, dev2, dev3 = platform.DEVICES
common_light.turn_on(hass, entity_id=dev2.entity_id)
ent1, ent2, ent3 = platform.ENTITIES
common_light.turn_on(hass, entity_id=ent2.entity_id)
await hass.async_block_till_done()
common_light.turn_on(hass, entity_id=dev3.entity_id)
common_light.turn_on(hass, entity_id=ent3.entity_id)
await hass.async_block_till_done()
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
state = hass.states.get(dev2.entity_id)
state = hass.states.get(ent2.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
state = hass.states.get(dev3.entity_id)
state = hass.states.get(ent3.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("xy_color") is None
assert state.attributes.get("brightness") is None
@@ -893,7 +893,7 @@ async def test_flux_with_multiple_lights(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id, dev2.entity_id, dev3.entity_id],
"lights": [ent1.entity_id, ent2.entity_id, ent3.entity_id],
}
},
)
@@ -921,10 +921,10 @@ async def test_flux_with_mired(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("color_temp") is None
@@ -950,7 +950,7 @@ async def test_flux_with_mired(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"mode": "mired",
}
},
@@ -972,10 +972,10 @@ async def test_flux_with_rgb(hass):
hass, light.DOMAIN, {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
dev1 = platform.DEVICES[0]
ent1 = platform.ENTITIES[0]
# Verify initial state of light
state = hass.states.get(dev1.entity_id)
state = hass.states.get(ent1.entity_id)
assert STATE_ON == state.state
assert state.attributes.get("color_temp") is None
@@ -1001,7 +1001,7 @@ async def test_flux_with_rgb(hass):
switch.DOMAIN: {
"platform": "flux",
"name": "flux",
"lights": [dev1.entity_id],
"lights": [ent1.entity_id],
"mode": "rgb",
}
},