Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Aug 14, 2024
1 parent 479343a commit 0b6ffd2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"tests/test_sensor_cleanup.py::test_sensor_cleanup": {
"https://api.github.com/repos/hacs/integration": 1,
"https://api.github.com/repos/hacs/integration/contents/custom_components/hacs/manifest.json": 1,
"https://api.github.com/repos/hacs/integration/contents/hacs.json": 1,
"https://api.github.com/repos/hacs/integration/git/trees/main": 1,
"https://api.github.com/repos/hacs/integration/releases": 1,
"https://data-v2.hacs.xyz/appdaemon/data.json": 1,
"https://data-v2.hacs.xyz/critical/data.json": 1,
"https://data-v2.hacs.xyz/integration/data.json": 1,
"https://data-v2.hacs.xyz/plugin/data.json": 1,
"https://data-v2.hacs.xyz/python_script/data.json": 1,
"https://data-v2.hacs.xyz/removed/data.json": 1,
"https://data-v2.hacs.xyz/template/data.json": 1,
"https://data-v2.hacs.xyz/theme/data.json": 1
}
}
32 changes: 32 additions & 0 deletions tests/test_sensor_cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Test the sensor cleanup."""

from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er

from custom_components.hacs.const import DOMAIN, HACS_SYSTEM_ID

from tests.common import create_config_entry, setup_integration


async def test_sensor_cleanup(hass: HomeAssistant) -> None:
"""Test the sensor cleanup."""
entity_registry = er.async_get(hass)
assert len(entity_registry.entities) == 0
entry = entity_registry.async_get_or_create(
domain="sensor",
platform=DOMAIN,
unique_id=HACS_SYSTEM_ID,
)

assert entity_registry.async_get(entry.entity_id) is not None

await setup_integration(
hass,
create_config_entry(
options={
"appdaemon": True,
},
),
)

assert entity_registry.async_get(entry.entity_id) is None

0 comments on commit 0b6ffd2

Please sign in to comment.