Remove deprecated YAML for Islamic prayer times (#72483)
parent
4ee92f3953
commit
0dd181f922
|
@ -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
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue