core/tests/components/jewish_calendar/conftest.py

29 lines
736 B
Python
Raw Normal View History

Add config flow to Jewish Calendar (#84464) * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Initial fixes for tests * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Fix bad merges in rebase * Get tests to run again * Fixes due to fails in ruff/pylint * Fix binary sensor tests * Fix config flow tests * Fix sensor tests * Apply review * Adjust candle lights * Apply suggestion * revert unrelated change * Address some of the comments * We should only allow a single jewish calendar config entry * Make data schema easier to read * Add test and confirm only single entry is allowed * Move OPTIONS_SCHEMA to top of file * Add options test * Simplify import tests * Test import end2end * Use a single async_forward_entry_setups statement * Revert schema updates for YAML schema * Remove unneeded brackets * Remove CONF_NAME from config_flow * Assign hass.data[DOMAIN][config_entry.entry_id] to a local variable before creating the sensors * Data doesn't have a name remove slugifying of it * Test that the entry has been created correctly * Simplify setup_entry * Use suggested values helper and flatten location dictionary * Remove the string for name exists as this error doesn't exist * Remove name from config entry * Remove _attr_has_entity_name - will be added in a subsequent PR * Don't override entity id's - we'll fixup the naming later * Make location optional - will by default revert to the user's home location * Update homeassistant/components/jewish_calendar/strings.json Co-authored-by: Erik Montnemery <erik@montnemery.com> * No need for local lat/long variable * Return name attribute, will deal with it in another PR * Revert unique_id changes, will deal with this in a subsequent PR * Add time zone data description * Don't break the YAML config until the user has removed it. * Cleanup initial config flow test --------- Co-authored-by: Tsvi Mostovicz <ttmost@gmail.com> Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-24 12:04:17 +00:00
"""Common fixtures for the jewish_calendar tests."""
from collections.abc import Generator
Add config flow to Jewish Calendar (#84464) * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Initial fixes for tests * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Fix bad merges in rebase * Get tests to run again * Fixes due to fails in ruff/pylint * Fix binary sensor tests * Fix config flow tests * Fix sensor tests * Apply review * Adjust candle lights * Apply suggestion * revert unrelated change * Address some of the comments * We should only allow a single jewish calendar config entry * Make data schema easier to read * Add test and confirm only single entry is allowed * Move OPTIONS_SCHEMA to top of file * Add options test * Simplify import tests * Test import end2end * Use a single async_forward_entry_setups statement * Revert schema updates for YAML schema * Remove unneeded brackets * Remove CONF_NAME from config_flow * Assign hass.data[DOMAIN][config_entry.entry_id] to a local variable before creating the sensors * Data doesn't have a name remove slugifying of it * Test that the entry has been created correctly * Simplify setup_entry * Use suggested values helper and flatten location dictionary * Remove the string for name exists as this error doesn't exist * Remove name from config entry * Remove _attr_has_entity_name - will be added in a subsequent PR * Don't override entity id's - we'll fixup the naming later * Make location optional - will by default revert to the user's home location * Update homeassistant/components/jewish_calendar/strings.json Co-authored-by: Erik Montnemery <erik@montnemery.com> * No need for local lat/long variable * Return name attribute, will deal with it in another PR * Revert unique_id changes, will deal with this in a subsequent PR * Add time zone data description * Don't break the YAML config until the user has removed it. * Cleanup initial config flow test --------- Co-authored-by: Tsvi Mostovicz <ttmost@gmail.com> Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-24 12:04:17 +00:00
from unittest.mock import AsyncMock, patch
import pytest
from homeassistant.components.jewish_calendar.const import DEFAULT_NAME, DOMAIN
Add config flow to Jewish Calendar (#84464) * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Initial fixes for tests * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Fix bad merges in rebase * Get tests to run again * Fixes due to fails in ruff/pylint * Fix binary sensor tests * Fix config flow tests * Fix sensor tests * Apply review * Adjust candle lights * Apply suggestion * revert unrelated change * Address some of the comments * We should only allow a single jewish calendar config entry * Make data schema easier to read * Add test and confirm only single entry is allowed * Move OPTIONS_SCHEMA to top of file * Add options test * Simplify import tests * Test import end2end * Use a single async_forward_entry_setups statement * Revert schema updates for YAML schema * Remove unneeded brackets * Remove CONF_NAME from config_flow * Assign hass.data[DOMAIN][config_entry.entry_id] to a local variable before creating the sensors * Data doesn't have a name remove slugifying of it * Test that the entry has been created correctly * Simplify setup_entry * Use suggested values helper and flatten location dictionary * Remove the string for name exists as this error doesn't exist * Remove name from config entry * Remove _attr_has_entity_name - will be added in a subsequent PR * Don't override entity id's - we'll fixup the naming later * Make location optional - will by default revert to the user's home location * Update homeassistant/components/jewish_calendar/strings.json Co-authored-by: Erik Montnemery <erik@montnemery.com> * No need for local lat/long variable * Return name attribute, will deal with it in another PR * Revert unique_id changes, will deal with this in a subsequent PR * Add time zone data description * Don't break the YAML config until the user has removed it. * Cleanup initial config flow test --------- Co-authored-by: Tsvi Mostovicz <ttmost@gmail.com> Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-24 12:04:17 +00:00
from tests.common import MockConfigEntry
@pytest.fixture
def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
title=DEFAULT_NAME,
domain=DOMAIN,
Add config flow to Jewish Calendar (#84464) * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Initial fixes for tests * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Fix bad merges in rebase * Get tests to run again * Fixes due to fails in ruff/pylint * Fix binary sensor tests * Fix config flow tests * Fix sensor tests * Apply review * Adjust candle lights * Apply suggestion * revert unrelated change * Address some of the comments * We should only allow a single jewish calendar config entry * Make data schema easier to read * Add test and confirm only single entry is allowed * Move OPTIONS_SCHEMA to top of file * Add options test * Simplify import tests * Test import end2end * Use a single async_forward_entry_setups statement * Revert schema updates for YAML schema * Remove unneeded brackets * Remove CONF_NAME from config_flow * Assign hass.data[DOMAIN][config_entry.entry_id] to a local variable before creating the sensors * Data doesn't have a name remove slugifying of it * Test that the entry has been created correctly * Simplify setup_entry * Use suggested values helper and flatten location dictionary * Remove the string for name exists as this error doesn't exist * Remove name from config entry * Remove _attr_has_entity_name - will be added in a subsequent PR * Don't override entity id's - we'll fixup the naming later * Make location optional - will by default revert to the user's home location * Update homeassistant/components/jewish_calendar/strings.json Co-authored-by: Erik Montnemery <erik@montnemery.com> * No need for local lat/long variable * Return name attribute, will deal with it in another PR * Revert unique_id changes, will deal with this in a subsequent PR * Add time zone data description * Don't break the YAML config until the user has removed it. * Cleanup initial config flow test --------- Co-authored-by: Tsvi Mostovicz <ttmost@gmail.com> Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-24 12:04:17 +00:00
)
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock]:
Add config flow to Jewish Calendar (#84464) * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Initial fixes for tests * Initial commit * add basic tests (will probably fail) * Set basic UID for now * Various improvements * use new naming convention? * bit by bit, still not working tho * Add tz selection * Remove failing tests * update unique_id * add the tests again * revert to previous binary_sensor test * remove translations * apply suggestions * remove const.py * Address review * revert changes * Fix bad merges in rebase * Get tests to run again * Fixes due to fails in ruff/pylint * Fix binary sensor tests * Fix config flow tests * Fix sensor tests * Apply review * Adjust candle lights * Apply suggestion * revert unrelated change * Address some of the comments * We should only allow a single jewish calendar config entry * Make data schema easier to read * Add test and confirm only single entry is allowed * Move OPTIONS_SCHEMA to top of file * Add options test * Simplify import tests * Test import end2end * Use a single async_forward_entry_setups statement * Revert schema updates for YAML schema * Remove unneeded brackets * Remove CONF_NAME from config_flow * Assign hass.data[DOMAIN][config_entry.entry_id] to a local variable before creating the sensors * Data doesn't have a name remove slugifying of it * Test that the entry has been created correctly * Simplify setup_entry * Use suggested values helper and flatten location dictionary * Remove the string for name exists as this error doesn't exist * Remove name from config entry * Remove _attr_has_entity_name - will be added in a subsequent PR * Don't override entity id's - we'll fixup the naming later * Make location optional - will by default revert to the user's home location * Update homeassistant/components/jewish_calendar/strings.json Co-authored-by: Erik Montnemery <erik@montnemery.com> * No need for local lat/long variable * Return name attribute, will deal with it in another PR * Revert unique_id changes, will deal with this in a subsequent PR * Add time zone data description * Don't break the YAML config until the user has removed it. * Cleanup initial config flow test --------- Co-authored-by: Tsvi Mostovicz <ttmost@gmail.com> Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-05-24 12:04:17 +00:00
"""Override async_setup_entry."""
with patch(
"homeassistant.components.jewish_calendar.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry