Skip to content

Commit

Permalink
Bump aiohasupervisor to version 0.2.1 (#129574)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Oct 31, 2024
1 parent f44b7e2 commit b09e54c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
7 changes: 4 additions & 3 deletions homeassistant/components/hassio/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import asyncio
import logging
from typing import Any
from uuid import UUID

from aiohasupervisor import SupervisorError
from aiohasupervisor.models import Discovery
Expand Down Expand Up @@ -86,7 +87,7 @@ async def post(self, request: web.Request, uuid: str) -> web.Response:
"""Handle new discovery requests."""
# Fetch discovery data and prevent injections
try:
data = await self._supervisor_client.discovery.get(uuid)
data = await self._supervisor_client.discovery.get(UUID(uuid))
except SupervisorError as err:
_LOGGER.error("Can't read discovery data: %s", err)
raise HTTPServiceUnavailable from None
Expand All @@ -104,7 +105,7 @@ async def delete(self, request: web.Request, uuid: str) -> web.Response:
async def async_rediscover(self, uuid: str) -> None:
"""Rediscover add-on when config entry is removed."""
try:
data = await self._supervisor_client.discovery.get(uuid)
data = await self._supervisor_client.discovery.get(UUID(uuid))
except SupervisorError as err:
_LOGGER.debug("Can't read discovery data: %s", err)
else:
Expand Down Expand Up @@ -146,7 +147,7 @@ async def async_process_del(self, data: dict[str, Any]) -> None:

# Check if really deletet / prevent injections
try:
data = await self._supervisor_client.discovery.get(uuid)
await self._supervisor_client.discovery.get(UUID(uuid))
except SupervisorError:
pass
else:
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/hassio/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def get_supervisor_client(hass: HomeAssistant) -> SupervisorClient:
"""Return supervisor client."""
hassio: HassIO = hass.data[DOMAIN]
return SupervisorClient(
hassio.base_url,
str(hassio.base_url),
os.environ.get("SUPERVISOR_TOKEN", ""),
session=hassio.websession,
)
2 changes: 1 addition & 1 deletion homeassistant/components/hassio/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"documentation": "https://www.home-assistant.io/integrations/hassio",
"iot_class": "local_polling",
"quality_scale": "internal",
"requirements": ["aiohasupervisor==0.2.0"],
"requirements": ["aiohasupervisor==0.2.1"],
"single_config_entry": true
}
2 changes: 1 addition & 1 deletion homeassistant/package_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
aiodhcpwatcher==1.0.2
aiodiscover==2.1.0
aiodns==3.2.0
aiohasupervisor==0.2.0
aiohasupervisor==0.2.1
aiohttp-fast-zlib==0.1.1
aiohttp==3.10.10
aiohttp_cors==0.7.0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
# Integrations may depend on hassio integration without listing it to
# change behavior based on presence of supervisor. Deprecated with #127228
# Lib can be removed with 2025.11
"aiohasupervisor==0.2.0",
"aiohasupervisor==0.2.1",
"aiohttp==3.10.10",
"aiohttp_cors==0.7.0",
"aiohttp-fast-zlib==0.1.1",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Home Assistant Core
aiodns==3.2.0
aiohasupervisor==0.2.0
aiohasupervisor==0.2.1
aiohttp==3.10.10
aiohttp_cors==0.7.0
aiohttp-fast-zlib==0.1.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ aioguardian==2022.07.0
aioharmony==0.2.10

# homeassistant.components.hassio
aiohasupervisor==0.2.0
aiohasupervisor==0.2.1

# homeassistant.components.homekit_controller
aiohomekit==3.2.5
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ aioguardian==2022.07.0
aioharmony==0.2.10

# homeassistant.components.hassio
aiohasupervisor==0.2.0
aiohasupervisor==0.2.1

# homeassistant.components.homekit_controller
aiohomekit==3.2.5
Expand Down
13 changes: 8 additions & 5 deletions tests/components/hassio/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ async def test_hassio_discovery_webhook(
addon_installed.return_value.name = "Mosquitto Test"

resp = await hassio_client.post(
"/api/hassio_push/discovery/testuuid",
json={"addon": "mosquitto", "service": "mqtt", "uuid": "testuuid"},
f"/api/hassio_push/discovery/{uuid!s}",
json={"addon": "mosquitto", "service": "mqtt", "uuid": str(uuid)},
)
await hass.async_block_till_done()
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
Expand All @@ -208,6 +208,9 @@ async def test_hassio_discovery_webhook(
)


TEST_UUID = str(uuid4())


@pytest.mark.parametrize(
(
"entry_domain",
Expand All @@ -217,13 +220,13 @@ async def test_hassio_discovery_webhook(
# Matching discovery key
(
"mock-domain",
{"hassio": (DiscoveryKey(domain="hassio", key="test", version=1),)},
{"hassio": (DiscoveryKey(domain="hassio", key=TEST_UUID, version=1),)},
),
# Matching discovery key
(
"mock-domain",
{
"hassio": (DiscoveryKey(domain="hassio", key="test", version=1),),
"hassio": (DiscoveryKey(domain="hassio", key=TEST_UUID, version=1),),
"other": (DiscoveryKey(domain="other", key="blah", version=1),),
},
),
Expand All @@ -232,7 +235,7 @@ async def test_hassio_discovery_webhook(
# entry. Such a check can be added if needed.
(
"comp",
{"hassio": (DiscoveryKey(domain="hassio", key="test", version=1),)},
{"hassio": (DiscoveryKey(domain="hassio", key=TEST_UUID, version=1),)},
),
],
)
Expand Down

0 comments on commit b09e54c

Please sign in to comment.