Remove deprecated YAML for Islamic prayer times (#72483)

This commit is contained in:
Rami Mosleh 2022-06-23 12:35:47 +03:00 committed by GitHub
parent 4ee92f3953
commit 0dd181f922
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 71 deletions

View File

@ -4,63 +4,30 @@ import logging
from prayer_times_calculator import PrayerTimesCalculator, exceptions from prayer_times_calculator import PrayerTimesCalculator, exceptions
from requests.exceptions import ConnectionError as ConnError 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.const import Platform
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_call_later, async_track_point_in_time 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 import homeassistant.util.dt as dt_util
from .const import ( from .const import CONF_CALC_METHOD, DATA_UPDATED, DEFAULT_CALC_METHOD, DOMAIN
CALC_METHODS,
CONF_CALC_METHOD,
DATA_UPDATED,
DEFAULT_CALC_METHOD,
DOMAIN,
)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
PLATFORMS = [Platform.SENSOR] PLATFORMS = [Platform.SENSOR]
CONFIG_SCHEMA = vol.Schema( CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False)
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
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Set up the Islamic Prayer Component.""" """Set up the Islamic Prayer Component."""
client = IslamicPrayerClient(hass, config_entry) client = IslamicPrayerClient(hass, config_entry)
if not await client.async_setup(): await client.async_setup()
return False
hass.data.setdefault(DOMAIN, client) hass.data.setdefault(DOMAIN, client)
return True return True

View File

@ -32,10 +32,6 @@ class IslamicPrayerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
return self.async_create_entry(title=NAME, data=user_input) 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): class IslamicPrayerOptionsFlowHandler(config_entries.OptionsFlow):
"""Handle Islamic Prayer client options.""" """Handle Islamic Prayer client options."""

View File

@ -59,19 +59,6 @@ async def test_options(hass):
assert result["data"][CONF_CALC_METHOD] == "makkah" 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): async def test_integration_already_configured(hass):
"""Test integration is already configured.""" """Test integration is already configured."""
entry = MockConfigEntry( entry = MockConfigEntry(

View File

@ -9,7 +9,6 @@ import pytest
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.components import islamic_prayer_times from homeassistant.components import islamic_prayer_times
from homeassistant.setup import async_setup_component
from . import ( from . import (
NEW_PRAYER_TIMES, NEW_PRAYER_TIMES,
@ -28,22 +27,6 @@ def set_utc(hass):
hass.config.set_time_zone("UTC") 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): async def test_successful_config_entry(hass):
"""Test that Islamic Prayer Times is configured successfully.""" """Test that Islamic Prayer Times is configured successfully."""