core/tests/components/bang_olufsen/conftest.py

61 lines
1.5 KiB
Python
Raw Normal View History

Add bang_olufsen integration (#93462) * Add bangolufsen integration * add untested files to .coveragerc * Simplify integration to media_player platform * Remove missing files from .coveragerc * Add beolink_set_relative_volume custom service Tweaks * Remove custom services Remove grouping as it was dependent on custom services * Update API to 3.2.1.150.0 Reduce and optimize code with feedback from joostlek Tweaks * Updated testing * Remove unused options schema * Fix bugfix setting wrong state * Fix wrong initial state * Bump API * Fix Beosound Level not reconnecting properly * Remove unused constant * Fix wrong variable checked to determine source * Update integration with feedback from emontnemery * Update integration with feedback from emontnemery * Remove unused code * Move API client into dataclass Fix not all config_flow exceptions caught Tweaks * Add Bang & Olufsen brand * Revert "Add Bang & Olufsen brand" This reverts commit 57b2722078ae0b563880306c6457d2cf3f528070. * Remove volume options from setup Simplify device checks rename integration to bang_olufsen update tests to pass Update API * Remove _device from base Add _device to websocket * Move SW version device update to websocket Sort websocket variables * Add WebSocket connection test * Remove unused constants * Remove confirmation form Make discovered devices get added to Home Assistant immediately Fix device not being available on mdns discovery Change config flow aborts to forms with error * Update tests for new config_flow Add missing api_exception test * Restrict manual and discovered IP addresses to IPv4 * Re-add confirmation step for zeroconf discovery Improve error messages Move exception mapping dict to module level * Enable remote control WebSocket listener * Update tests
2024-01-24 11:00:51 +00:00
"""Test fixtures for bang_olufsen."""
from collections.abc import Generator
Add bang_olufsen integration (#93462) * Add bangolufsen integration * add untested files to .coveragerc * Simplify integration to media_player platform * Remove missing files from .coveragerc * Add beolink_set_relative_volume custom service Tweaks * Remove custom services Remove grouping as it was dependent on custom services * Update API to 3.2.1.150.0 Reduce and optimize code with feedback from joostlek Tweaks * Updated testing * Remove unused options schema * Fix bugfix setting wrong state * Fix wrong initial state * Bump API * Fix Beosound Level not reconnecting properly * Remove unused constant * Fix wrong variable checked to determine source * Update integration with feedback from emontnemery * Update integration with feedback from emontnemery * Remove unused code * Move API client into dataclass Fix not all config_flow exceptions caught Tweaks * Add Bang & Olufsen brand * Revert "Add Bang & Olufsen brand" This reverts commit 57b2722078ae0b563880306c6457d2cf3f528070. * Remove volume options from setup Simplify device checks rename integration to bang_olufsen update tests to pass Update API * Remove _device from base Add _device to websocket * Move SW version device update to websocket Sort websocket variables * Add WebSocket connection test * Remove unused constants * Remove confirmation form Make discovered devices get added to Home Assistant immediately Fix device not being available on mdns discovery Change config flow aborts to forms with error * Update tests for new config_flow Add missing api_exception test * Restrict manual and discovered IP addresses to IPv4 * Re-add confirmation step for zeroconf discovery Improve error messages Move exception mapping dict to module level * Enable remote control WebSocket listener * Update tests
2024-01-24 11:00:51 +00:00
from unittest.mock import AsyncMock, patch
from mozart_api.models import BeolinkPeer
import pytest
from homeassistant.components.bang_olufsen.const import DOMAIN
from .const import (
TEST_DATA_CREATE_ENTRY,
TEST_FRIENDLY_NAME,
TEST_JID_1,
TEST_NAME,
TEST_SERIAL_NUMBER,
)
from tests.common import MockConfigEntry
@pytest.fixture
def mock_config_entry():
"""Mock config entry."""
return MockConfigEntry(
domain=DOMAIN,
unique_id=TEST_SERIAL_NUMBER,
data=TEST_DATA_CREATE_ENTRY,
title=TEST_NAME,
)
@pytest.fixture
def mock_mozart_client() -> Generator[AsyncMock, None, None]:
Add bang_olufsen integration (#93462) * Add bangolufsen integration * add untested files to .coveragerc * Simplify integration to media_player platform * Remove missing files from .coveragerc * Add beolink_set_relative_volume custom service Tweaks * Remove custom services Remove grouping as it was dependent on custom services * Update API to 3.2.1.150.0 Reduce and optimize code with feedback from joostlek Tweaks * Updated testing * Remove unused options schema * Fix bugfix setting wrong state * Fix wrong initial state * Bump API * Fix Beosound Level not reconnecting properly * Remove unused constant * Fix wrong variable checked to determine source * Update integration with feedback from emontnemery * Update integration with feedback from emontnemery * Remove unused code * Move API client into dataclass Fix not all config_flow exceptions caught Tweaks * Add Bang & Olufsen brand * Revert "Add Bang & Olufsen brand" This reverts commit 57b2722078ae0b563880306c6457d2cf3f528070. * Remove volume options from setup Simplify device checks rename integration to bang_olufsen update tests to pass Update API * Remove _device from base Add _device to websocket * Move SW version device update to websocket Sort websocket variables * Add WebSocket connection test * Remove unused constants * Remove confirmation form Make discovered devices get added to Home Assistant immediately Fix device not being available on mdns discovery Change config flow aborts to forms with error * Update tests for new config_flow Add missing api_exception test * Restrict manual and discovered IP addresses to IPv4 * Re-add confirmation step for zeroconf discovery Improve error messages Move exception mapping dict to module level * Enable remote control WebSocket listener * Update tests
2024-01-24 11:00:51 +00:00
"""Mock MozartClient."""
with (
patch(
"homeassistant.components.bang_olufsen.MozartClient", autospec=True
) as mock_client,
patch(
"homeassistant.components.bang_olufsen.config_flow.MozartClient",
new=mock_client,
),
):
client = mock_client.return_value
client.get_beolink_self = AsyncMock()
client.get_beolink_self.return_value = BeolinkPeer(
friendly_name=TEST_FRIENDLY_NAME, jid=TEST_JID_1
)
Add bang_olufsen integration (#93462) * Add bangolufsen integration * add untested files to .coveragerc * Simplify integration to media_player platform * Remove missing files from .coveragerc * Add beolink_set_relative_volume custom service Tweaks * Remove custom services Remove grouping as it was dependent on custom services * Update API to 3.2.1.150.0 Reduce and optimize code with feedback from joostlek Tweaks * Updated testing * Remove unused options schema * Fix bugfix setting wrong state * Fix wrong initial state * Bump API * Fix Beosound Level not reconnecting properly * Remove unused constant * Fix wrong variable checked to determine source * Update integration with feedback from emontnemery * Update integration with feedback from emontnemery * Remove unused code * Move API client into dataclass Fix not all config_flow exceptions caught Tweaks * Add Bang & Olufsen brand * Revert "Add Bang & Olufsen brand" This reverts commit 57b2722078ae0b563880306c6457d2cf3f528070. * Remove volume options from setup Simplify device checks rename integration to bang_olufsen update tests to pass Update API * Remove _device from base Add _device to websocket * Move SW version device update to websocket Sort websocket variables * Add WebSocket connection test * Remove unused constants * Remove confirmation form Make discovered devices get added to Home Assistant immediately Fix device not being available on mdns discovery Change config flow aborts to forms with error * Update tests for new config_flow Add missing api_exception test * Restrict manual and discovered IP addresses to IPv4 * Re-add confirmation step for zeroconf discovery Improve error messages Move exception mapping dict to module level * Enable remote control WebSocket listener * Update tests
2024-01-24 11:00:51 +00:00
yield client
@pytest.fixture
def mock_setup_entry():
"""Mock successful setup entry."""
with patch(
"homeassistant.components.bang_olufsen.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry