Internally work with modern config syntax for template binary sensor platform config (#48981)

This commit is contained in:
Paulus Schoutsen
2021-04-13 07:58:44 -07:00
committed by GitHub
parent 82790cd28d
commit beea2dd35f
2 changed files with 163 additions and 52 deletions
@@ -26,13 +26,19 @@ async def test_setup(hass):
"sensors": {
"test": {
"friendly_name": "virtual thingy",
"value_template": "{{ foo }}",
"value_template": "{{ True }}",
"device_class": "motion",
}
},
}
}
assert await setup.async_setup_component(hass, binary_sensor.DOMAIN, config)
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.test")
assert state is not None
assert state.name == "virtual thingy"
assert state.state == "on"
assert state.attributes["device_class"] == "motion"
async def test_setup_no_sensors(hass):
@@ -40,6 +46,8 @@ async def test_setup_no_sensors(hass):
assert await setup.async_setup_component(
hass, binary_sensor.DOMAIN, {"binary_sensor": {"platform": "template"}}
)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids()) == 0
async def test_setup_invalid_device(hass):
@@ -49,6 +57,8 @@ async def test_setup_invalid_device(hass):
binary_sensor.DOMAIN,
{"binary_sensor": {"platform": "template", "sensors": {"foo bar": {}}}},
)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids()) == 0
async def test_setup_invalid_device_class(hass):
@@ -68,6 +78,8 @@ async def test_setup_invalid_device_class(hass):
}
},
)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids()) == 0
async def test_setup_invalid_missing_template(hass):
@@ -82,6 +94,8 @@ async def test_setup_invalid_missing_template(hass):
}
},
)
await hass.async_block_till_done()
assert len(hass.states.async_entity_ids()) == 0
async def test_icon_template(hass):