From 0dd181f9221155f8004a0bb6203bc2ab5bf3525c Mon Sep 17 00:00:00 2001 From: Rami Mosleh Date: Thu, 23 Jun 2022 12:35:47 +0300 Subject: [PATCH] Remove deprecated YAML for Islamic prayer times (#72483) --- .../islamic_prayer_times/__init__.py | 41 ++----------------- .../islamic_prayer_times/config_flow.py | 4 -- .../islamic_prayer_times/test_config_flow.py | 13 ------ .../islamic_prayer_times/test_init.py | 17 -------- 4 files changed, 4 insertions(+), 71 deletions(-) diff --git a/homeassistant/components/islamic_prayer_times/__init__.py b/homeassistant/components/islamic_prayer_times/__init__.py index c88e26e1c90..406eaf23670 100644 --- a/homeassistant/components/islamic_prayer_times/__init__.py +++ b/homeassistant/components/islamic_prayer_times/__init__.py @@ -4,63 +4,30 @@ import logging from prayer_times_calculator import PrayerTimesCalculator, exceptions from requests.exceptions import ConnectionError as ConnError -import voluptuous as vol -from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry +from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_call_later, async_track_point_in_time -from homeassistant.helpers.typing import ConfigType import homeassistant.util.dt as dt_util -from .const import ( - CALC_METHODS, - CONF_CALC_METHOD, - DATA_UPDATED, - DEFAULT_CALC_METHOD, - DOMAIN, -) +from .const import CONF_CALC_METHOD, DATA_UPDATED, DEFAULT_CALC_METHOD, DOMAIN _LOGGER = logging.getLogger(__name__) PLATFORMS = [Platform.SENSOR] -CONFIG_SCHEMA = vol.Schema( - vol.All( - cv.deprecated(DOMAIN), - { - DOMAIN: { - vol.Optional(CONF_CALC_METHOD, default=DEFAULT_CALC_METHOD): vol.In( - CALC_METHODS - ), - } - }, - ), - extra=vol.ALLOW_EXTRA, -) - - -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Import the Islamic Prayer component from config.""" - if DOMAIN in config: - hass.async_create_task( - hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config[DOMAIN] - ) - ) - - return True +CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False) async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up the Islamic Prayer Component.""" client = IslamicPrayerClient(hass, config_entry) - if not await client.async_setup(): - return False + await client.async_setup() hass.data.setdefault(DOMAIN, client) return True diff --git a/homeassistant/components/islamic_prayer_times/config_flow.py b/homeassistant/components/islamic_prayer_times/config_flow.py index 3379af3860f..5278750d36e 100644 --- a/homeassistant/components/islamic_prayer_times/config_flow.py +++ b/homeassistant/components/islamic_prayer_times/config_flow.py @@ -32,10 +32,6 @@ class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): return self.async_create_entry(title=NAME, data=user_input) - async def async_step_import(self, import_config): - """Import from config.""" - return await self.async_step_user(user_input=import_config) - class IslamicPrayerOptionsFlowHandler(config_entries.OptionsFlow): """Handle Islamic Prayer client options.""" diff --git a/tests/components/islamic_prayer_times/test_config_flow.py b/tests/components/islamic_prayer_times/test_config_flow.py index 18d64842c65..730c5634770 100644 --- a/tests/components/islamic_prayer_times/test_config_flow.py +++ b/tests/components/islamic_prayer_times/test_config_flow.py @@ -59,19 +59,6 @@ async def test_options(hass): assert result["data"][CONF_CALC_METHOD] == "makkah" -async def test_import(hass): - """Test import step.""" - result = await hass.config_entries.flow.async_init( - islamic_prayer_times.DOMAIN, - context={"source": config_entries.SOURCE_IMPORT}, - data={CONF_CALC_METHOD: "makkah"}, - ) - - assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY - assert result["title"] == "Islamic Prayer Times" - assert result["data"][CONF_CALC_METHOD] == "makkah" - - async def test_integration_already_configured(hass): """Test integration is already configured.""" entry = MockConfigEntry( diff --git a/tests/components/islamic_prayer_times/test_init.py b/tests/components/islamic_prayer_times/test_init.py index e40af8c89ff..5a092373eef 100644 --- a/tests/components/islamic_prayer_times/test_init.py +++ b/tests/components/islamic_prayer_times/test_init.py @@ -9,7 +9,6 @@ import pytest from homeassistant import config_entries from homeassistant.components import islamic_prayer_times -from homeassistant.setup import async_setup_component from . import ( NEW_PRAYER_TIMES, @@ -28,22 +27,6 @@ def set_utc(hass): hass.config.set_time_zone("UTC") -async def test_setup_with_config(hass): - """Test that we import the config and setup the client.""" - config = { - islamic_prayer_times.DOMAIN: {islamic_prayer_times.CONF_CALC_METHOD: "isna"} - } - with patch( - "prayer_times_calculator.PrayerTimesCalculator.fetch_prayer_times", - return_value=PRAYER_TIMES, - ): - assert ( - await async_setup_component(hass, islamic_prayer_times.DOMAIN, config) - is True - ) - await hass.async_block_till_done() - - async def test_successful_config_entry(hass): """Test that Islamic Prayer Times is configured successfully."""