Remove counter configure service (#103204)

* Remove counter configure service after deprecation

* reproduce state
This commit is contained in:
G Johansson 2023-11-04 16:17:51 +01:00 committed by GitHub
parent 2d3318e767
commit 72c02d4d63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 206 deletions

View file

@ -24,7 +24,7 @@ from homeassistant.components.counter import (
)
from homeassistant.const import ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME, ATTR_ICON, ATTR_NAME
from homeassistant.core import Context, CoreState, HomeAssistant, State
from homeassistant.helpers import entity_registry as er, issue_registry as ir
from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component
from .common import async_decrement, async_increment, async_reset
@ -432,148 +432,6 @@ async def test_counter_max(hass: HomeAssistant, hass_admin_user: MockUser) -> No
assert state2.state == "-1"
async def test_configure(
hass: HomeAssistant, hass_admin_user: MockUser, issue_registry: ir.IssueRegistry
) -> None:
"""Test that setting values through configure works."""
assert await async_setup_component(
hass, "counter", {"counter": {"test": {"maximum": "10", "initial": "10"}}}
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "10"
assert state.attributes.get("maximum") == 10
# update max
await hass.services.async_call(
"counter",
"configure",
{"entity_id": state.entity_id, "maximum": 0},
True,
Context(user_id=hass_admin_user.id),
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "0"
assert state.attributes.get("maximum") == 0
# Ensure an issue is raised for the use of this deprecated service
assert issue_registry.async_get_issue(
domain=DOMAIN, issue_id="deprecated_configure_service"
)
# disable max
await hass.services.async_call(
"counter",
"configure",
{"entity_id": state.entity_id, "maximum": None},
True,
Context(user_id=hass_admin_user.id),
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "0"
assert state.attributes.get("maximum") is None
# update min
assert state.attributes.get("minimum") is None
await hass.services.async_call(
"counter",
"configure",
{"entity_id": state.entity_id, "minimum": 5},
True,
Context(user_id=hass_admin_user.id),
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "5"
assert state.attributes.get("minimum") == 5
# disable min
await hass.services.async_call(
"counter",
"configure",
{"entity_id": state.entity_id, "minimum": None},
True,
Context(user_id=hass_admin_user.id),
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "5"
assert state.attributes.get("minimum") is None
# update step
assert state.attributes.get("step") == 1
await hass.services.async_call(
"counter",
"configure",
{"entity_id": state.entity_id, "step": 3},
True,
Context(user_id=hass_admin_user.id),
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "5"
assert state.attributes.get("step") == 3
# update value
await hass.services.async_call(
"counter",
"configure",
{"entity_id": state.entity_id, "value": 6},
True,
Context(user_id=hass_admin_user.id),
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "6"
# update initial
await hass.services.async_call(
"counter",
"configure",
{"entity_id": state.entity_id, "initial": 5},
True,
Context(user_id=hass_admin_user.id),
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "6"
assert state.attributes.get("initial") == 5
# update all
await hass.services.async_call(
"counter",
"configure",
{
"entity_id": state.entity_id,
"step": 5,
"minimum": 0,
"maximum": 9,
"value": 5,
"initial": 6,
},
True,
Context(user_id=hass_admin_user.id),
)
state = hass.states.get("counter.test")
assert state is not None
assert state.state == "5"
assert state.attributes.get("step") == 5
assert state.attributes.get("minimum") == 0
assert state.attributes.get("maximum") == 9
assert state.attributes.get("initial") == 6
async def test_load_from_storage(hass: HomeAssistant, storage_setup) -> None:
"""Test set up from storage."""
assert await storage_setup()