Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
"""Tests for the MadVR remote entity."""
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
|
2024-07-23 16:06:26 +00:00
|
|
|
import pytest
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
from syrupy import SnapshotAssertion
|
|
|
|
|
2024-07-23 16:06:26 +00:00
|
|
|
from homeassistant.components.remote import (
|
|
|
|
DOMAIN as REMOTE_DOMAIN,
|
|
|
|
SERVICE_SEND_COMMAND,
|
|
|
|
)
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
from homeassistant.const import (
|
2024-07-23 16:06:26 +00:00
|
|
|
ATTR_COMMAND,
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
ATTR_ENTITY_ID,
|
|
|
|
SERVICE_TURN_OFF,
|
|
|
|
SERVICE_TURN_ON,
|
|
|
|
STATE_ON,
|
|
|
|
Platform,
|
|
|
|
)
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
import homeassistant.helpers.entity_registry as er
|
|
|
|
|
|
|
|
from . import setup_integration
|
2024-07-23 16:06:26 +00:00
|
|
|
from .const import (
|
|
|
|
TEST_COMMAND,
|
|
|
|
TEST_CON_ERROR,
|
|
|
|
TEST_FAILED_CMD,
|
|
|
|
TEST_FAILED_OFF,
|
|
|
|
TEST_FAILED_ON,
|
|
|
|
TEST_IMP_ERROR,
|
|
|
|
)
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
|
|
|
|
from tests.common import MockConfigEntry, snapshot_platform
|
|
|
|
|
|
|
|
|
|
|
|
async def test_remote_setup(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
snapshot: SnapshotAssertion,
|
|
|
|
mock_config_entry: MockConfigEntry,
|
|
|
|
entity_registry: er.EntityRegistry,
|
|
|
|
) -> None:
|
|
|
|
"""Test setup of the remote entity."""
|
|
|
|
with patch("homeassistant.components.madvr.PLATFORMS", [Platform.REMOTE]):
|
|
|
|
await setup_integration(hass, mock_config_entry)
|
|
|
|
|
|
|
|
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
|
|
|
|
|
|
|
|
|
|
|
async def test_remote_power(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
mock_madvr_client: AsyncMock,
|
|
|
|
mock_config_entry: MockConfigEntry,
|
2024-07-23 16:06:26 +00:00
|
|
|
caplog: pytest.LogCaptureFixture,
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test turning on the remote entity."""
|
|
|
|
|
|
|
|
await setup_integration(hass, mock_config_entry)
|
|
|
|
|
|
|
|
entity_id = "remote.madvr_envy"
|
|
|
|
remote = hass.states.get(entity_id)
|
|
|
|
assert remote.state == STATE_ON
|
|
|
|
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True
|
|
|
|
)
|
|
|
|
|
|
|
|
mock_madvr_client.power_off.assert_called_once()
|
|
|
|
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id}, blocking=True
|
|
|
|
)
|
|
|
|
await hass.async_block_till_done()
|
|
|
|
|
|
|
|
mock_madvr_client.power_on.assert_called_once()
|
|
|
|
|
2024-07-23 16:06:26 +00:00
|
|
|
# cover exception cases
|
|
|
|
caplog.clear()
|
|
|
|
mock_madvr_client.power_off.side_effect = TEST_CON_ERROR
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True
|
|
|
|
)
|
|
|
|
assert TEST_FAILED_OFF in caplog.text
|
|
|
|
|
|
|
|
# Test turning off with NotImplementedError
|
|
|
|
caplog.clear()
|
|
|
|
mock_madvr_client.power_off.side_effect = TEST_IMP_ERROR
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id}, blocking=True
|
|
|
|
)
|
|
|
|
assert TEST_FAILED_OFF in caplog.text
|
|
|
|
|
|
|
|
# Reset side_effect for power_off
|
|
|
|
mock_madvr_client.power_off.side_effect = None
|
|
|
|
|
|
|
|
# Test turning on with ConnectionError
|
|
|
|
caplog.clear()
|
|
|
|
mock_madvr_client.power_on.side_effect = TEST_CON_ERROR
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id}, blocking=True
|
|
|
|
)
|
|
|
|
assert TEST_FAILED_ON in caplog.text
|
|
|
|
|
|
|
|
# Test turning on with NotImplementedError
|
|
|
|
caplog.clear()
|
|
|
|
mock_madvr_client.power_on.side_effect = TEST_IMP_ERROR
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id}, blocking=True
|
|
|
|
)
|
|
|
|
assert TEST_FAILED_ON in caplog.text
|
|
|
|
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
|
|
|
|
async def test_send_command(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
mock_madvr_client: AsyncMock,
|
|
|
|
mock_config_entry: MockConfigEntry,
|
2024-07-23 16:06:26 +00:00
|
|
|
caplog: pytest.LogCaptureFixture,
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
) -> None:
|
|
|
|
"""Test sending command to the remote entity."""
|
|
|
|
|
|
|
|
await setup_integration(hass, mock_config_entry)
|
|
|
|
|
|
|
|
entity_id = "remote.madvr_envy"
|
|
|
|
remote = hass.states.get(entity_id)
|
|
|
|
assert remote.state == STATE_ON
|
|
|
|
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN,
|
2024-07-23 16:06:26 +00:00
|
|
|
SERVICE_SEND_COMMAND,
|
|
|
|
{ATTR_ENTITY_ID: entity_id, ATTR_COMMAND: TEST_COMMAND},
|
|
|
|
blocking=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
mock_madvr_client.add_command_to_queue.assert_called_once_with([TEST_COMMAND])
|
|
|
|
# cover exceptions
|
|
|
|
# Test ConnectionError
|
|
|
|
mock_madvr_client.add_command_to_queue.side_effect = TEST_CON_ERROR
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN,
|
|
|
|
SERVICE_SEND_COMMAND,
|
|
|
|
{ATTR_ENTITY_ID: entity_id, ATTR_COMMAND: TEST_COMMAND},
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
blocking=True,
|
|
|
|
)
|
2024-07-23 16:06:26 +00:00
|
|
|
assert TEST_FAILED_CMD in caplog.text
|
Add madvr envy integration (#120382)
* feat: Add madvr envy
* fix: await and pass entry directly
* fix: add attributes and unique id for sensors
* fix: reflect power state well, improve state detection
* fix: don't connect on init, add options, add reload on change, keep on during test
* fix: cancel tasks on unload
* fix: test connection via library
* fix: wait for boot time
* docs: add readme and license
* fix: broken pipe in lib
* fix: detect out of band power off
* fix: improve extra attributes
* fix: fix unloading, add config flow test, limit to one platform
* fix: use conf, refresh coordinator, other comments
* fix: remove event data
* fix: fix tests passing, remove wake on lan
* fix: dont allow to proceed unless connection works
* chore: update dep
* fix: update config flow, add constants
* fix: write state, use runtime data instead
* fix: remove await
* fix: move unloading and stuff to coordinator/init
* fix: pass in config entry with correct type
* fix: move queue and tasks to library
* fix: config flow error flow, tests, name, and update lib
* fix: update lib, leave connection open on setup
* fix: update lib
* fix: address comments, remove wol from lib
* fix: remove unneeded options
* fix: remove fields
* fix: simplify code, address comments
* fix: move error to lib
* fix: fix test
* fix: stronger types
* fix: update lib
* fix: missing text from options flow
* chore: remove options flow
* chore: remove import
* chore: update comments
* fix: get mac from device, persist
* fix: add mac stuff to test
* fix: startup import errors
* chore: stale comment
* fix: get mac from persisted config
* chore: update lib
* fix: persist mac in a better way
* feat: use mac as unique ID for entry
* fix: use unique ID from mac, add proper device
* fix: will not be set in init potentially
* fix: access mac
* fix: optimize, move error to lib
* feat: add coordinator test, use conf
* fix: use one mock, add init test
* fix: not async
* feat: add remote test
* fix: types
* fix: patch client, expand remote tests
* fix: use snapshot test
* fix: update branding
* fix: add description, fix type check
* fix: update tests
* fix: test
* fix: update test
* fix: camelcase
* Fix
* feat: strict typing
* fix: strict typing in lib
* fix: type will never be None
* fix: reference to mac, all tests passing
---------
Co-authored-by: Joostlek <joostlek@outlook.com>
2024-07-07 18:41:53 +00:00
|
|
|
|
2024-07-23 16:06:26 +00:00
|
|
|
# Test NotImplementedError
|
|
|
|
mock_madvr_client.add_command_to_queue.side_effect = TEST_IMP_ERROR
|
|
|
|
await hass.services.async_call(
|
|
|
|
REMOTE_DOMAIN,
|
|
|
|
SERVICE_SEND_COMMAND,
|
|
|
|
{ATTR_ENTITY_ID: entity_id, ATTR_COMMAND: TEST_COMMAND},
|
|
|
|
blocking=True,
|
|
|
|
)
|
|
|
|
assert TEST_FAILED_CMD in caplog.text
|