mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Move Jewish calendar constants to const file (#118180)
* Move Jewish calendar constants to const file * Add a few missed constants * Move CONF_LANGUAGE to it's correct path
This commit is contained in:
parent
0972b29510
commit
11646cab5f
@ -20,15 +20,17 @@ import homeassistant.helpers.config_validation as cv
|
|||||||
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
DOMAIN = "jewish_calendar"
|
from .const import (
|
||||||
CONF_DIASPORA = "diaspora"
|
CONF_CANDLE_LIGHT_MINUTES,
|
||||||
CONF_CANDLE_LIGHT_MINUTES = "candle_lighting_minutes_before_sunset"
|
CONF_DIASPORA,
|
||||||
CONF_HAVDALAH_OFFSET_MINUTES = "havdalah_minutes_after_sunset"
|
CONF_HAVDALAH_OFFSET_MINUTES,
|
||||||
DEFAULT_NAME = "Jewish Calendar"
|
DEFAULT_CANDLE_LIGHT,
|
||||||
DEFAULT_CANDLE_LIGHT = 18
|
DEFAULT_DIASPORA,
|
||||||
DEFAULT_DIASPORA = False
|
DEFAULT_HAVDALAH_OFFSET_MINUTES,
|
||||||
DEFAULT_HAVDALAH_OFFSET_MINUTES = 0
|
DEFAULT_LANGUAGE,
|
||||||
DEFAULT_LANGUAGE = "english"
|
DEFAULT_NAME,
|
||||||
|
DOMAIN,
|
||||||
|
)
|
||||||
|
|
||||||
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.SENSOR]
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from . import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
@ -32,15 +32,17 @@ from homeassistant.helpers.selector import (
|
|||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
|
|
||||||
DOMAIN = "jewish_calendar"
|
from .const import (
|
||||||
CONF_DIASPORA = "diaspora"
|
CONF_CANDLE_LIGHT_MINUTES,
|
||||||
CONF_CANDLE_LIGHT_MINUTES = "candle_lighting_minutes_before_sunset"
|
CONF_DIASPORA,
|
||||||
CONF_HAVDALAH_OFFSET_MINUTES = "havdalah_minutes_after_sunset"
|
CONF_HAVDALAH_OFFSET_MINUTES,
|
||||||
DEFAULT_NAME = "Jewish Calendar"
|
DEFAULT_CANDLE_LIGHT,
|
||||||
DEFAULT_CANDLE_LIGHT = 18
|
DEFAULT_DIASPORA,
|
||||||
DEFAULT_DIASPORA = False
|
DEFAULT_HAVDALAH_OFFSET_MINUTES,
|
||||||
DEFAULT_HAVDALAH_OFFSET_MINUTES = 0
|
DEFAULT_LANGUAGE,
|
||||||
DEFAULT_LANGUAGE = "english"
|
DEFAULT_NAME,
|
||||||
|
DOMAIN,
|
||||||
|
)
|
||||||
|
|
||||||
LANGUAGE = [
|
LANGUAGE = [
|
||||||
SelectOptionDict(value="hebrew", label="Hebrew"),
|
SelectOptionDict(value="hebrew", label="Hebrew"),
|
||||||
|
13
homeassistant/components/jewish_calendar/const.py
Normal file
13
homeassistant/components/jewish_calendar/const.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
"""Jewish Calendar constants."""
|
||||||
|
|
||||||
|
DOMAIN = "jewish_calendar"
|
||||||
|
|
||||||
|
CONF_DIASPORA = "diaspora"
|
||||||
|
CONF_CANDLE_LIGHT_MINUTES = "candle_lighting_minutes_before_sunset"
|
||||||
|
CONF_HAVDALAH_OFFSET_MINUTES = "havdalah_minutes_after_sunset"
|
||||||
|
|
||||||
|
DEFAULT_NAME = "Jewish Calendar"
|
||||||
|
DEFAULT_CANDLE_LIGHT = 18
|
||||||
|
DEFAULT_DIASPORA = False
|
||||||
|
DEFAULT_HAVDALAH_OFFSET_MINUTES = 0
|
||||||
|
DEFAULT_LANGUAGE = "english"
|
@ -22,7 +22,7 @@ from homeassistant.helpers.sun import get_astral_event_date
|
|||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from . import DEFAULT_NAME, DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from unittest.mock import AsyncMock, patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.jewish_calendar import config_flow
|
from homeassistant.components.jewish_calendar.const import DEFAULT_NAME, DOMAIN
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
@ -14,8 +14,8 @@ from tests.common import MockConfigEntry
|
|||||||
def mock_config_entry() -> MockConfigEntry:
|
def mock_config_entry() -> MockConfigEntry:
|
||||||
"""Return the default mocked config entry."""
|
"""Return the default mocked config entry."""
|
||||||
return MockConfigEntry(
|
return MockConfigEntry(
|
||||||
title=config_flow.DEFAULT_NAME,
|
title=DEFAULT_NAME,
|
||||||
domain=config_flow.DOMAIN,
|
domain=DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,11 +5,10 @@ from unittest.mock import AsyncMock
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries, setup
|
||||||
from homeassistant.components.jewish_calendar import (
|
from homeassistant.components.jewish_calendar.const import (
|
||||||
CONF_CANDLE_LIGHT_MINUTES,
|
CONF_CANDLE_LIGHT_MINUTES,
|
||||||
CONF_DIASPORA,
|
CONF_DIASPORA,
|
||||||
CONF_HAVDALAH_OFFSET_MINUTES,
|
CONF_HAVDALAH_OFFSET_MINUTES,
|
||||||
CONF_LANGUAGE,
|
|
||||||
DEFAULT_CANDLE_LIGHT,
|
DEFAULT_CANDLE_LIGHT,
|
||||||
DEFAULT_DIASPORA,
|
DEFAULT_DIASPORA,
|
||||||
DEFAULT_HAVDALAH_OFFSET_MINUTES,
|
DEFAULT_HAVDALAH_OFFSET_MINUTES,
|
||||||
@ -19,6 +18,7 @@ from homeassistant.components.jewish_calendar import (
|
|||||||
from homeassistant.config_entries import SOURCE_USER
|
from homeassistant.config_entries import SOURCE_USER
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_ELEVATION,
|
CONF_ELEVATION,
|
||||||
|
CONF_LANGUAGE,
|
||||||
CONF_LATITUDE,
|
CONF_LATITUDE,
|
||||||
CONF_LONGITUDE,
|
CONF_LONGITUDE,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
|
@ -4,8 +4,8 @@ from datetime import datetime as dt, timedelta
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import jewish_calendar
|
|
||||||
from homeassistant.components.binary_sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.binary_sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
|
from homeassistant.components.jewish_calendar.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
@ -17,7 +17,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
|
|||||||
|
|
||||||
async def test_jewish_calendar_min_config(hass: HomeAssistant) -> None:
|
async def test_jewish_calendar_min_config(hass: HomeAssistant) -> None:
|
||||||
"""Test minimum jewish calendar configuration."""
|
"""Test minimum jewish calendar configuration."""
|
||||||
entry = MockConfigEntry(domain=jewish_calendar.DOMAIN, data={})
|
entry = MockConfigEntry(domain=DOMAIN, data={})
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -26,7 +26,7 @@ async def test_jewish_calendar_min_config(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
async def test_jewish_calendar_hebrew(hass: HomeAssistant) -> None:
|
async def test_jewish_calendar_hebrew(hass: HomeAssistant) -> None:
|
||||||
"""Test jewish calendar sensor with language set to hebrew."""
|
"""Test jewish calendar sensor with language set to hebrew."""
|
||||||
entry = MockConfigEntry(domain=jewish_calendar.DOMAIN, data={"language": "hebrew"})
|
entry = MockConfigEntry(domain=DOMAIN, data={"language": "hebrew"})
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -167,7 +167,7 @@ async def test_jewish_calendar_sensor(
|
|||||||
|
|
||||||
with alter_time(test_time):
|
with alter_time(test_time):
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
domain=jewish_calendar.DOMAIN,
|
domain=DOMAIN,
|
||||||
data={
|
data={
|
||||||
"language": language,
|
"language": language,
|
||||||
"diaspora": diaspora,
|
"diaspora": diaspora,
|
||||||
@ -509,7 +509,7 @@ async def test_shabbat_times_sensor(
|
|||||||
|
|
||||||
with alter_time(test_time):
|
with alter_time(test_time):
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
domain=jewish_calendar.DOMAIN,
|
domain=DOMAIN,
|
||||||
data={
|
data={
|
||||||
"language": language,
|
"language": language,
|
||||||
"diaspora": diaspora,
|
"diaspora": diaspora,
|
||||||
@ -566,7 +566,7 @@ async def test_omer_sensor(hass: HomeAssistant, test_time, result) -> None:
|
|||||||
test_time = test_time.replace(tzinfo=dt_util.get_time_zone(hass.config.time_zone))
|
test_time = test_time.replace(tzinfo=dt_util.get_time_zone(hass.config.time_zone))
|
||||||
|
|
||||||
with alter_time(test_time):
|
with alter_time(test_time):
|
||||||
entry = MockConfigEntry(domain=jewish_calendar.DOMAIN)
|
entry = MockConfigEntry(domain=DOMAIN)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -600,7 +600,7 @@ async def test_dafyomi_sensor(hass: HomeAssistant, test_time, result) -> None:
|
|||||||
test_time = test_time.replace(tzinfo=dt_util.get_time_zone(hass.config.time_zone))
|
test_time = test_time.replace(tzinfo=dt_util.get_time_zone(hass.config.time_zone))
|
||||||
|
|
||||||
with alter_time(test_time):
|
with alter_time(test_time):
|
||||||
entry = MockConfigEntry(domain=jewish_calendar.DOMAIN)
|
entry = MockConfigEntry(domain=DOMAIN)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
await hass.config_entries.async_setup(entry.entry_id)
|
await hass.config_entries.async_setup(entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -620,7 +620,7 @@ async def test_no_discovery_info(
|
|||||||
assert await async_setup_component(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
SENSOR_DOMAIN,
|
SENSOR_DOMAIN,
|
||||||
{SENSOR_DOMAIN: {"platform": jewish_calendar.DOMAIN}},
|
{SENSOR_DOMAIN: {"platform": DOMAIN}},
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert SENSOR_DOMAIN in hass.config.components
|
assert SENSOR_DOMAIN in hass.config.components
|
||||||
|
Loading…
x
Reference in New Issue
Block a user