mirror of
https://github.com/home-assistant/core.git
synced 2025-09-06 05:11:35 +02:00
Bump hass-nabucasa from 0.111.2 to 1.0.0 and refactor related code (#150566)
This commit is contained in:
@@ -7,7 +7,7 @@ from http import HTTPStatus
|
|||||||
import logging
|
import logging
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
from hass_nabucasa import Cloud, cloud_api
|
from hass_nabucasa import Cloud
|
||||||
from hass_nabucasa.google_report_state import ErrorResponse
|
from hass_nabucasa.google_report_state import ErrorResponse
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||||
@@ -377,7 +377,7 @@ class CloudGoogleConfig(AbstractConfig):
|
|||||||
return HTTPStatus.OK
|
return HTTPStatus.OK
|
||||||
|
|
||||||
async with self._sync_entities_lock:
|
async with self._sync_entities_lock:
|
||||||
resp = await cloud_api.async_google_actions_request_sync(self._cloud)
|
resp = await self._cloud.google_report_state.request_sync()
|
||||||
return resp.status
|
return resp.status
|
||||||
|
|
||||||
async def async_connect_agent_user(self, agent_user_id: str) -> None:
|
async def async_connect_agent_user(self, agent_user_id: str) -> None:
|
||||||
|
@@ -13,6 +13,6 @@
|
|||||||
"integration_type": "system",
|
"integration_type": "system",
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"loggers": ["acme", "hass_nabucasa", "snitun"],
|
"loggers": ["acme", "hass_nabucasa", "snitun"],
|
||||||
"requirements": ["hass-nabucasa==0.111.2"],
|
"requirements": ["hass-nabucasa==1.0.0"],
|
||||||
"single_config_entry": true
|
"single_config_entry": true
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ fnv-hash-fast==1.5.0
|
|||||||
go2rtc-client==0.2.1
|
go2rtc-client==0.2.1
|
||||||
ha-ffmpeg==3.2.2
|
ha-ffmpeg==3.2.2
|
||||||
habluetooth==5.0.1
|
habluetooth==5.0.1
|
||||||
hass-nabucasa==0.111.2
|
hass-nabucasa==1.0.0
|
||||||
hassil==3.1.0
|
hassil==3.1.0
|
||||||
home-assistant-bluetooth==1.13.1
|
home-assistant-bluetooth==1.13.1
|
||||||
home-assistant-frontend==20250811.0
|
home-assistant-frontend==20250811.0
|
||||||
|
@@ -47,7 +47,7 @@ dependencies = [
|
|||||||
"fnv-hash-fast==1.5.0",
|
"fnv-hash-fast==1.5.0",
|
||||||
# hass-nabucasa is imported by helpers which don't depend on the cloud
|
# hass-nabucasa is imported by helpers which don't depend on the cloud
|
||||||
# integration
|
# integration
|
||||||
"hass-nabucasa==0.111.2",
|
"hass-nabucasa==1.0.0",
|
||||||
# When bumping httpx, please check the version pins of
|
# When bumping httpx, please check the version pins of
|
||||||
# httpcore, anyio, and h11 in gen_requirements_all
|
# httpcore, anyio, and h11 in gen_requirements_all
|
||||||
"httpx==0.28.1",
|
"httpx==0.28.1",
|
||||||
|
2
requirements.txt
generated
2
requirements.txt
generated
@@ -22,7 +22,7 @@ certifi>=2021.5.30
|
|||||||
ciso8601==2.3.2
|
ciso8601==2.3.2
|
||||||
cronsim==2.6
|
cronsim==2.6
|
||||||
fnv-hash-fast==1.5.0
|
fnv-hash-fast==1.5.0
|
||||||
hass-nabucasa==0.111.2
|
hass-nabucasa==1.0.0
|
||||||
httpx==0.28.1
|
httpx==0.28.1
|
||||||
home-assistant-bluetooth==1.13.1
|
home-assistant-bluetooth==1.13.1
|
||||||
ifaddr==0.2.0
|
ifaddr==0.2.0
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@@ -1133,7 +1133,7 @@ habiticalib==0.4.2
|
|||||||
habluetooth==5.0.1
|
habluetooth==5.0.1
|
||||||
|
|
||||||
# homeassistant.components.cloud
|
# homeassistant.components.cloud
|
||||||
hass-nabucasa==0.111.2
|
hass-nabucasa==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.splunk
|
# homeassistant.components.splunk
|
||||||
hass-splunk==0.1.1
|
hass-splunk==0.1.1
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@@ -994,7 +994,7 @@ habiticalib==0.4.2
|
|||||||
habluetooth==5.0.1
|
habluetooth==5.0.1
|
||||||
|
|
||||||
# homeassistant.components.cloud
|
# homeassistant.components.cloud
|
||||||
hass-nabucasa==0.111.2
|
hass-nabucasa==1.0.0
|
||||||
|
|
||||||
# homeassistant.components.assist_satellite
|
# homeassistant.components.assist_satellite
|
||||||
# homeassistant.components.conversation
|
# homeassistant.components.conversation
|
||||||
|
@@ -55,7 +55,10 @@ async def cloud_fixture() -> AsyncGenerator[MagicMock]:
|
|||||||
# Attributes set in the constructor without parameters.
|
# Attributes set in the constructor without parameters.
|
||||||
# We spec the mocks with the real classes
|
# We spec the mocks with the real classes
|
||||||
# and set constructor attributes or mock properties as needed.
|
# and set constructor attributes or mock properties as needed.
|
||||||
mock_cloud.google_report_state = MagicMock(spec=GoogleReportState)
|
mock_cloud.google_report_state = MagicMock(
|
||||||
|
spec=GoogleReportState,
|
||||||
|
request_sync=AsyncMock(),
|
||||||
|
)
|
||||||
mock_cloud.cloudhooks = MagicMock(spec=Cloudhooks)
|
mock_cloud.cloudhooks = MagicMock(spec=Cloudhooks)
|
||||||
mock_cloud.remote = MagicMock(
|
mock_cloud.remote = MagicMock(
|
||||||
spec=RemoteUI,
|
spec=RemoteUI,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
"""Test the Cloud Google Config."""
|
"""Test the Cloud Google Config."""
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import Mock, PropertyMock, patch
|
from unittest.mock import AsyncMock, Mock, PropertyMock, patch
|
||||||
|
|
||||||
from freezegun import freeze_time
|
from freezegun import freeze_time
|
||||||
import pytest
|
import pytest
|
||||||
@@ -119,15 +119,13 @@ async def test_sync_entities(
|
|||||||
|
|
||||||
assert len(mock_conf.async_get_agent_users()) == 1
|
assert len(mock_conf.async_get_agent_users()) == 1
|
||||||
|
|
||||||
with patch(
|
mock_conf._cloud.google_report_state.request_sync = AsyncMock(
|
||||||
"hass_nabucasa.cloud_api.async_google_actions_request_sync",
|
return_value=Mock(status=HTTPStatus.NOT_FOUND)
|
||||||
return_value=Mock(status=HTTPStatus.NOT_FOUND),
|
)
|
||||||
) as mock_request_sync:
|
|
||||||
assert (
|
assert await mock_conf.async_sync_entities("mock-user-id") == HTTPStatus.NOT_FOUND
|
||||||
await mock_conf.async_sync_entities("mock-user-id") == HTTPStatus.NOT_FOUND
|
assert len(mock_conf.async_get_agent_users()) == 0
|
||||||
)
|
assert len(mock_conf._cloud.google_report_state.request_sync.mock_calls) == 1
|
||||||
assert len(mock_conf.async_get_agent_users()) == 0
|
|
||||||
assert len(mock_request_sync.mock_calls) == 1
|
|
||||||
|
|
||||||
|
|
||||||
async def test_google_update_expose_trigger_sync(
|
async def test_google_update_expose_trigger_sync(
|
||||||
|
@@ -139,31 +139,34 @@ async def setup_cloud_fixture(hass: HomeAssistant, cloud: MagicMock) -> None:
|
|||||||
async def test_google_actions_sync(
|
async def test_google_actions_sync(
|
||||||
setup_cloud: None,
|
setup_cloud: None,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
|
cloud: MagicMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test syncing Google Actions."""
|
"""Test syncing Google Actions."""
|
||||||
cloud_client = await hass_client()
|
cloud_client = await hass_client()
|
||||||
with patch(
|
|
||||||
"hass_nabucasa.cloud_api.async_google_actions_request_sync",
|
cloud.google_report_state.request_sync = AsyncMock(
|
||||||
return_value=Mock(status=200),
|
return_value=Mock(status=HTTPStatus.OK)
|
||||||
) as mock_request_sync:
|
)
|
||||||
req = await cloud_client.post("/api/cloud/google_actions/sync")
|
|
||||||
assert req.status == HTTPStatus.OK
|
req = await cloud_client.post("/api/cloud/google_actions/sync")
|
||||||
assert mock_request_sync.call_count == 1
|
assert req.status == HTTPStatus.OK
|
||||||
|
assert len(cloud.google_report_state.request_sync.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_google_actions_sync_fails(
|
async def test_google_actions_sync_fails(
|
||||||
setup_cloud: None,
|
setup_cloud: None,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
|
cloud: MagicMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test syncing Google Actions gone bad."""
|
"""Test syncing Google Actions gone bad."""
|
||||||
cloud_client = await hass_client()
|
cloud_client = await hass_client()
|
||||||
with patch(
|
cloud.google_report_state.request_sync = AsyncMock(
|
||||||
"hass_nabucasa.cloud_api.async_google_actions_request_sync",
|
return_value=Mock(status=HTTPStatus.INTERNAL_SERVER_ERROR)
|
||||||
return_value=Mock(status=HTTPStatus.INTERNAL_SERVER_ERROR),
|
)
|
||||||
) as mock_request_sync:
|
|
||||||
req = await cloud_client.post("/api/cloud/google_actions/sync")
|
req = await cloud_client.post("/api/cloud/google_actions/sync")
|
||||||
assert req.status == HTTPStatus.INTERNAL_SERVER_ERROR
|
assert req.status == HTTPStatus.INTERNAL_SERVER_ERROR
|
||||||
assert mock_request_sync.call_count == 1
|
assert len(cloud.google_report_state.request_sync.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Reference in New Issue
Block a user