Remove unused calls fixture from template tests (#71735)
parent
1ef3800844
commit
b70e97e949
|
@ -2,8 +2,6 @@
|
|||
import datetime as dt
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant import setup
|
||||
from homeassistant.components.button.const import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.components.template.button import DEFAULT_NAME
|
||||
|
@ -16,19 +14,13 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.helpers.entity_registry import async_get
|
||||
|
||||
from tests.common import assert_setup_component, async_mock_service
|
||||
from tests.common import assert_setup_component
|
||||
|
||||
_TEST_BUTTON = "button.template_button"
|
||||
_TEST_OPTIONS_BUTTON = "button.test"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def calls(hass):
|
||||
"""Track calls to a mock service."""
|
||||
return async_mock_service(hass, "test", "automation")
|
||||
|
||||
|
||||
async def test_missing_optional_config(hass, calls):
|
||||
async def test_missing_optional_config(hass):
|
||||
"""Test: missing optional template is ok."""
|
||||
with assert_setup_component(1, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -50,7 +42,7 @@ async def test_missing_optional_config(hass, calls):
|
|||
_verify(hass, STATE_UNKNOWN)
|
||||
|
||||
|
||||
async def test_missing_required_keys(hass, calls):
|
||||
async def test_missing_required_keys(hass):
|
||||
"""Test: missing required fields will fail."""
|
||||
with assert_setup_component(0, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -128,7 +120,7 @@ async def test_all_optional_config(hass, calls):
|
|||
assert er.async_get_entity_id("button", "template", "test-test")
|
||||
|
||||
|
||||
async def test_name_template(hass, calls):
|
||||
async def test_name_template(hass):
|
||||
"""Test: name template."""
|
||||
with assert_setup_component(1, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -158,7 +150,7 @@ async def test_name_template(hass, calls):
|
|||
)
|
||||
|
||||
|
||||
async def test_unique_id(hass, calls):
|
||||
async def test_unique_id(hass):
|
||||
"""Test: unique id is ok."""
|
||||
with assert_setup_component(1, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
|
|
@ -396,7 +396,7 @@ async def test_on_off(hass):
|
|||
_verify(hass, state, 0, None, None, None)
|
||||
|
||||
|
||||
async def test_set_invalid_direction_from_initial_stage(hass, calls):
|
||||
async def test_set_invalid_direction_from_initial_stage(hass):
|
||||
"""Test set invalid direction when fan is in initial state."""
|
||||
await _register_components(hass)
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
"""The tests for the Template number platform."""
|
||||
import pytest
|
||||
|
||||
from homeassistant import setup
|
||||
from homeassistant.components.input_number import (
|
||||
|
@ -19,11 +18,7 @@ from homeassistant.const import ATTR_ICON, CONF_ENTITY_ID, STATE_UNKNOWN
|
|||
from homeassistant.core import Context
|
||||
from homeassistant.helpers.entity_registry import async_get
|
||||
|
||||
from tests.common import (
|
||||
assert_setup_component,
|
||||
async_capture_events,
|
||||
async_mock_service,
|
||||
)
|
||||
from tests.common import assert_setup_component, async_capture_events
|
||||
|
||||
_TEST_NUMBER = "number.template_number"
|
||||
# Represent for number's value
|
||||
|
@ -47,13 +42,7 @@ _VALUE_INPUT_NUMBER_CONFIG = {
|
|||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def calls(hass):
|
||||
"""Track calls to a mock service."""
|
||||
return async_mock_service(hass, "test", "automation")
|
||||
|
||||
|
||||
async def test_missing_optional_config(hass, calls):
|
||||
async def test_missing_optional_config(hass):
|
||||
"""Test: missing optional template is ok."""
|
||||
with assert_setup_component(1, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -77,7 +66,7 @@ async def test_missing_optional_config(hass, calls):
|
|||
_verify(hass, 4, 1, 0.0, 100.0)
|
||||
|
||||
|
||||
async def test_missing_required_keys(hass, calls):
|
||||
async def test_missing_required_keys(hass):
|
||||
"""Test: missing required fields will fail."""
|
||||
with assert_setup_component(0, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -112,7 +101,7 @@ async def test_missing_required_keys(hass, calls):
|
|||
assert hass.states.async_all("number") == []
|
||||
|
||||
|
||||
async def test_all_optional_config(hass, calls):
|
||||
async def test_all_optional_config(hass):
|
||||
"""Test: including all optional templates is ok."""
|
||||
with assert_setup_component(1, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -138,7 +127,7 @@ async def test_all_optional_config(hass, calls):
|
|||
_verify(hass, 4, 1, 3, 5)
|
||||
|
||||
|
||||
async def test_templates_with_entities(hass, calls):
|
||||
async def test_templates_with_entities(hass):
|
||||
"""Test templates with values from other entities."""
|
||||
with assert_setup_component(4, "input_number"):
|
||||
assert await setup.async_setup_component(
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
"""The tests for the Template select platform."""
|
||||
import pytest
|
||||
|
||||
from homeassistant import setup
|
||||
from homeassistant.components.input_select import (
|
||||
ATTR_OPTION as INPUT_SELECT_ATTR_OPTION,
|
||||
|
@ -19,24 +17,14 @@ from homeassistant.const import ATTR_ICON, CONF_ENTITY_ID, STATE_UNKNOWN
|
|||
from homeassistant.core import Context
|
||||
from homeassistant.helpers.entity_registry import async_get
|
||||
|
||||
from tests.common import (
|
||||
assert_setup_component,
|
||||
async_capture_events,
|
||||
async_mock_service,
|
||||
)
|
||||
from tests.common import assert_setup_component, async_capture_events
|
||||
|
||||
_TEST_SELECT = "select.template_select"
|
||||
# Represent for select's current_option
|
||||
_OPTION_INPUT_SELECT = "input_select.option"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def calls(hass):
|
||||
"""Track calls to a mock service."""
|
||||
return async_mock_service(hass, "test", "automation")
|
||||
|
||||
|
||||
async def test_missing_optional_config(hass, calls):
|
||||
async def test_missing_optional_config(hass):
|
||||
"""Test: missing optional template is ok."""
|
||||
with assert_setup_component(1, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -60,7 +48,7 @@ async def test_missing_optional_config(hass, calls):
|
|||
_verify(hass, "a", ["a", "b"])
|
||||
|
||||
|
||||
async def test_multiple_configs(hass, calls):
|
||||
async def test_multiple_configs(hass):
|
||||
"""Test: multiple select entities get created."""
|
||||
with assert_setup_component(1, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -92,7 +80,7 @@ async def test_multiple_configs(hass, calls):
|
|||
_verify(hass, "a", ["a", "b"], f"{_TEST_SELECT}_2")
|
||||
|
||||
|
||||
async def test_missing_required_keys(hass, calls):
|
||||
async def test_missing_required_keys(hass):
|
||||
"""Test: missing required fields will fail."""
|
||||
with assert_setup_component(0, "template"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -143,7 +131,7 @@ async def test_missing_required_keys(hass, calls):
|
|||
assert hass.states.async_all("select") == []
|
||||
|
||||
|
||||
async def test_templates_with_entities(hass, calls):
|
||||
async def test_templates_with_entities(hass):
|
||||
"""Test templates with values from other entities."""
|
||||
with assert_setup_component(1, "input_select"):
|
||||
assert await setup.async_setup_component(
|
||||
|
@ -290,7 +278,7 @@ def _verify(hass, expected_current_option, expected_options, entity_name=_TEST_S
|
|||
assert attributes.get(SELECT_ATTR_OPTIONS) == expected_options
|
||||
|
||||
|
||||
async def test_template_icon_with_entities(hass, calls):
|
||||
async def test_template_icon_with_entities(hass):
|
||||
"""Test templates with values from other entities."""
|
||||
with assert_setup_component(1, "input_select"):
|
||||
assert await setup.async_setup_component(
|
||||
|
|
Loading…
Reference in New Issue