From 7c46eb5952146812c32d39bcfe77c4be1e2c6d99 Mon Sep 17 00:00:00 2001 From: Yuval Aboulafia Date: Mon, 2 May 2022 20:52:00 +0300 Subject: [PATCH] Add test for incorrect config for Jewish Calendar (#71163) * Loop load Jewish Calendar platforms * Address review * Add test for incorrect config * add test to sensor platform --- .../jewish_calendar/test_binary_sensor.py | 13 +++++++++++++ tests/components/jewish_calendar/test_sensor.py | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/tests/components/jewish_calendar/test_binary_sensor.py b/tests/components/jewish_calendar/test_binary_sensor.py index 31cc0095af1..3ecac44b59c 100644 --- a/tests/components/jewish_calendar/test_binary_sensor.py +++ b/tests/components/jewish_calendar/test_binary_sensor.py @@ -4,6 +4,7 @@ from datetime import datetime as dt, timedelta import pytest from homeassistant.components import jewish_calendar +from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN from homeassistant.const import STATE_OFF, STATE_ON from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component @@ -302,3 +303,15 @@ async def test_issur_melacha_sensor_update( hass.states.get("binary_sensor.test_issur_melacha_in_effect").state == result[1] ) + + +async def test_no_discovery_info(hass, caplog): + """Test setup without discovery info.""" + assert BINARY_SENSOR_DOMAIN not in hass.config.components + assert await async_setup_component( + hass, + BINARY_SENSOR_DOMAIN, + {BINARY_SENSOR_DOMAIN: {"platform": jewish_calendar.DOMAIN}}, + ) + await hass.async_block_till_done() + assert BINARY_SENSOR_DOMAIN in hass.config.components diff --git a/tests/components/jewish_calendar/test_sensor.py b/tests/components/jewish_calendar/test_sensor.py index d7d62a7ac97..a5dae8b4ce7 100644 --- a/tests/components/jewish_calendar/test_sensor.py +++ b/tests/components/jewish_calendar/test_sensor.py @@ -4,6 +4,7 @@ from datetime import datetime as dt, timedelta import pytest from homeassistant.components import jewish_calendar +from homeassistant.components.binary_sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component import homeassistant.util.dt as dt_util @@ -639,3 +640,15 @@ async def test_dafyomi_sensor(hass, test_time, result): await hass.async_block_till_done() assert hass.states.get("sensor.test_daf_yomi").state == result + + +async def test_no_discovery_info(hass, caplog): + """Test setup without discovery info.""" + assert SENSOR_DOMAIN not in hass.config.components + assert await async_setup_component( + hass, + SENSOR_DOMAIN, + {SENSOR_DOMAIN: {"platform": jewish_calendar.DOMAIN}}, + ) + await hass.async_block_till_done() + assert SENSOR_DOMAIN in hass.config.components