Extract Withings API specifics in own class (#100363)

* Extract Withings API specifics in own class

* Extract Withings API specifics in own class

* Ignore api test coverage

* fix feedback
This commit is contained in:
Joost Lekkerkerker
2023-09-14 13:31:54 +02:00
committed by GitHub
parent b858658516
commit 6fc1407613
5 changed files with 214 additions and 125 deletions
+4 -4
View File
@@ -15,7 +15,7 @@ from homeassistant.components.application_credentials import (
ClientCredential,
async_import_client_credential,
)
from homeassistant.components.withings.common import ConfigEntryWithingsApi
from homeassistant.components.withings.api import ConfigEntryWithingsApi
from homeassistant.components.withings.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
@@ -112,13 +112,13 @@ def mock_withings():
mock.user_get_device.return_value = UserGetDeviceResponse(
**load_json_object_fixture("withings/get_device.json")
)
mock.measure_get_meas.return_value = MeasureGetMeasResponse(
mock.async_measure_get_meas.return_value = MeasureGetMeasResponse(
**load_json_object_fixture("withings/get_meas.json")
)
mock.sleep_get_summary.return_value = SleepGetSummaryResponse(
mock.async_sleep_get_summary.return_value = SleepGetSummaryResponse(
**load_json_object_fixture("withings/get_sleep.json")
)
mock.notify_list.return_value = NotifyListResponse(
mock.async_notify_list.return_value = NotifyListResponse(
**load_json_object_fixture("withings/notify_list.json")
)
+9 -7
View File
@@ -117,17 +117,19 @@ async def test_data_manager_webhook_subscription(
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=1))
await hass.async_block_till_done()
assert withings.notify_subscribe.call_count == 4
assert withings.async_notify_subscribe.call_count == 4
webhook_url = "http://example.local:8123/api/webhook/55a7335ea8dee830eed4ef8f84cda8f6d80b83af0847dc74032e86120bffed5e"
withings.notify_subscribe.assert_any_call(webhook_url, NotifyAppli.WEIGHT)
withings.notify_subscribe.assert_any_call(webhook_url, NotifyAppli.CIRCULATORY)
withings.notify_subscribe.assert_any_call(webhook_url, NotifyAppli.ACTIVITY)
withings.notify_subscribe.assert_any_call(webhook_url, NotifyAppli.SLEEP)
withings.async_notify_subscribe.assert_any_call(webhook_url, NotifyAppli.WEIGHT)
withings.async_notify_subscribe.assert_any_call(
webhook_url, NotifyAppli.CIRCULATORY
)
withings.async_notify_subscribe.assert_any_call(webhook_url, NotifyAppli.ACTIVITY)
withings.async_notify_subscribe.assert_any_call(webhook_url, NotifyAppli.SLEEP)
withings.notify_revoke.assert_any_call(webhook_url, NotifyAppli.BED_IN)
withings.notify_revoke.assert_any_call(webhook_url, NotifyAppli.BED_OUT)
withings.async_notify_revoke.assert_any_call(webhook_url, NotifyAppli.BED_IN)
withings.async_notify_revoke.assert_any_call(webhook_url, NotifyAppli.BED_OUT)
@pytest.mark.parametrize(