core/tests/components/lamarzocco/conftest.py

138 lines
4.1 KiB
Python
Raw Normal View History

"""Lamarzocco session fixtures."""
from collections.abc import Generator
from unittest.mock import MagicMock, patch
from lmcloud.const import LaMarzoccoModel
import pytest
from homeassistant.components.lamarzocco.const import CONF_MACHINE, DOMAIN
Add Bluetooth support to La Marzocco integration (#108287) * init * init tests * linting * checks * tests, linting * pylint * add tests * switch tests * add water heater tests * change icons * extra args cleanup * moar tests * services tests * remove extra platforms * test for unique id * back to single instance * add diagnostics * remove extra platforms * test for unique id * back to single instance * Add better connection management for Idasen Desk (#102135) * Return 'None' for light attributes when off instead of removing them (#101946) * Bump home-assistant-bluetooth to 1.10.4 (#102268) * Bump orjson to 3.9.9 (#102267) * Bump opower to 0.0.37 (#102265) * Bump Python-Roborock to 0.35.0 (#102275) * Add CodeQL CI Job (#102273) * Remove unused dsmr sensors (#102223) * rebase messed up conftest * more tests for init * add client to coveragerc * add client to coveragerc * next lmcloud version * strict typing * more typing * allow multiple machines * remove unneeded var * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/diagnostics.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * PR suggestions * remove base exception * Update manifest.json * update lmcloud * update lmcloud * remove ignore * selection bugfix for machines with space in name * bugfix temps * add options flow * send out full user input * remove options flow * split the tests to avoid timeouts * use selectoptionsdict for selection * removing rccoleman * improve test coverage to 100% * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * autoselect cloud machine for discovered machine * move default values to 3rd party lib * bring property changes from lmcloud * moving things to lmcloud * move validation to method * move more things to lmcloud * remove unused const * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * remove callback from coordinator * remove waterheater, add switch * improvement to background task * next lmcloud * adapt to lib changes * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * requested changes * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * some requested changes * changes * requested changes * move steam boiler to controls * fix: remove entities from GS3MP model + tests * remove dataclass decorator * next lmcloud version * improvements * move reauth to user step * improve config flow * remove asserts in favor of runtimeerrors * undo conftest comment * make duc return none * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * remove diagnostics, changes * refine config flow * remove runtimeerrors in favor of asserts * move initialization of lm_client to coordinator * remove things from lmclient * remove lm_client * remove lm_client * bump lm version * correctly set initialized for tests * move exception handling inside init + tests * add test for switch without bluetooth on * bump lmcloud * pass httpx client to LMLocalAPI * add call function to reduce code * switch to snapshot testing * remove bluetooth * bump version * cleanup import * remove unused const * set correct integration_type * correct default selection in CF * reduce unnecessary tests by fixture change * use other json loads helpers * move prebrew/infusion to select entity * bump lmcloud * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * requested feedback * step description, bump lmcloud * create init integration functino * revert * ruff * remove leftover BT test * make main switch main entity * bump lmcloud * re-add bluetooth * improve * bump firmware (again) * correct test * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * separate device test * add BT to entites * fix import * docstring * minor * fix rebase * get device from discovered devices * tweak * change tests * switch to dict * switch to options * fix * fix --------- Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: Paul Bottein <paul.bottein@gmail.com> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: tronikos <tronikos@users.noreply.github.com> Co-authored-by: Luke Lashley <conway220@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: dupondje <jean-louis@dupond.be> Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-03-21 12:08:11 +00:00
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME
from homeassistant.core import HomeAssistant
Add Bluetooth support to La Marzocco integration (#108287) * init * init tests * linting * checks * tests, linting * pylint * add tests * switch tests * add water heater tests * change icons * extra args cleanup * moar tests * services tests * remove extra platforms * test for unique id * back to single instance * add diagnostics * remove extra platforms * test for unique id * back to single instance * Add better connection management for Idasen Desk (#102135) * Return 'None' for light attributes when off instead of removing them (#101946) * Bump home-assistant-bluetooth to 1.10.4 (#102268) * Bump orjson to 3.9.9 (#102267) * Bump opower to 0.0.37 (#102265) * Bump Python-Roborock to 0.35.0 (#102275) * Add CodeQL CI Job (#102273) * Remove unused dsmr sensors (#102223) * rebase messed up conftest * more tests for init * add client to coveragerc * add client to coveragerc * next lmcloud version * strict typing * more typing * allow multiple machines * remove unneeded var * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/diagnostics.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * PR suggestions * remove base exception * Update manifest.json * update lmcloud * update lmcloud * remove ignore * selection bugfix for machines with space in name * bugfix temps * add options flow * send out full user input * remove options flow * split the tests to avoid timeouts * use selectoptionsdict for selection * removing rccoleman * improve test coverage to 100% * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * autoselect cloud machine for discovered machine * move default values to 3rd party lib * bring property changes from lmcloud * moving things to lmcloud * move validation to method * move more things to lmcloud * remove unused const * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * remove callback from coordinator * remove waterheater, add switch * improvement to background task * next lmcloud * adapt to lib changes * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * requested changes * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * some requested changes * changes * requested changes * move steam boiler to controls * fix: remove entities from GS3MP model + tests * remove dataclass decorator * next lmcloud version * improvements * move reauth to user step * improve config flow * remove asserts in favor of runtimeerrors * undo conftest comment * make duc return none * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * remove diagnostics, changes * refine config flow * remove runtimeerrors in favor of asserts * move initialization of lm_client to coordinator * remove things from lmclient * remove lm_client * remove lm_client * bump lm version * correctly set initialized for tests * move exception handling inside init + tests * add test for switch without bluetooth on * bump lmcloud * pass httpx client to LMLocalAPI * add call function to reduce code * switch to snapshot testing * remove bluetooth * bump version * cleanup import * remove unused const * set correct integration_type * correct default selection in CF * reduce unnecessary tests by fixture change * use other json loads helpers * move prebrew/infusion to select entity * bump lmcloud * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * requested feedback * step description, bump lmcloud * create init integration functino * revert * ruff * remove leftover BT test * make main switch main entity * bump lmcloud * re-add bluetooth * improve * bump firmware (again) * correct test * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * separate device test * add BT to entites * fix import * docstring * minor * fix rebase * get device from discovered devices * tweak * change tests * switch to dict * switch to options * fix * fix --------- Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: Paul Bottein <paul.bottein@gmail.com> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: tronikos <tronikos@users.noreply.github.com> Co-authored-by: Luke Lashley <conway220@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: dupondje <jean-louis@dupond.be> Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-03-21 12:08:11 +00:00
from . import MODEL_DICT, USER_INPUT, async_init_integration
from tests.common import (
MockConfigEntry,
load_json_array_fixture,
load_json_object_fixture,
)
@pytest.fixture
def mock_config_entry(
hass: HomeAssistant, mock_lamarzocco: MagicMock
) -> MockConfigEntry:
"""Return the default mocked config entry."""
entry = MockConfigEntry(
title="My LaMarzocco",
domain=DOMAIN,
data=USER_INPUT
Add Bluetooth support to La Marzocco integration (#108287) * init * init tests * linting * checks * tests, linting * pylint * add tests * switch tests * add water heater tests * change icons * extra args cleanup * moar tests * services tests * remove extra platforms * test for unique id * back to single instance * add diagnostics * remove extra platforms * test for unique id * back to single instance * Add better connection management for Idasen Desk (#102135) * Return 'None' for light attributes when off instead of removing them (#101946) * Bump home-assistant-bluetooth to 1.10.4 (#102268) * Bump orjson to 3.9.9 (#102267) * Bump opower to 0.0.37 (#102265) * Bump Python-Roborock to 0.35.0 (#102275) * Add CodeQL CI Job (#102273) * Remove unused dsmr sensors (#102223) * rebase messed up conftest * more tests for init * add client to coveragerc * add client to coveragerc * next lmcloud version * strict typing * more typing * allow multiple machines * remove unneeded var * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/diagnostics.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * PR suggestions * remove base exception * Update manifest.json * update lmcloud * update lmcloud * remove ignore * selection bugfix for machines with space in name * bugfix temps * add options flow * send out full user input * remove options flow * split the tests to avoid timeouts * use selectoptionsdict for selection * removing rccoleman * improve test coverage to 100% * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * autoselect cloud machine for discovered machine * move default values to 3rd party lib * bring property changes from lmcloud * moving things to lmcloud * move validation to method * move more things to lmcloud * remove unused const * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * remove callback from coordinator * remove waterheater, add switch * improvement to background task * next lmcloud * adapt to lib changes * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * requested changes * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * some requested changes * changes * requested changes * move steam boiler to controls * fix: remove entities from GS3MP model + tests * remove dataclass decorator * next lmcloud version * improvements * move reauth to user step * improve config flow * remove asserts in favor of runtimeerrors * undo conftest comment * make duc return none * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * remove diagnostics, changes * refine config flow * remove runtimeerrors in favor of asserts * move initialization of lm_client to coordinator * remove things from lmclient * remove lm_client * remove lm_client * bump lm version * correctly set initialized for tests * move exception handling inside init + tests * add test for switch without bluetooth on * bump lmcloud * pass httpx client to LMLocalAPI * add call function to reduce code * switch to snapshot testing * remove bluetooth * bump version * cleanup import * remove unused const * set correct integration_type * correct default selection in CF * reduce unnecessary tests by fixture change * use other json loads helpers * move prebrew/infusion to select entity * bump lmcloud * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * requested feedback * step description, bump lmcloud * create init integration functino * revert * ruff * remove leftover BT test * make main switch main entity * bump lmcloud * re-add bluetooth * improve * bump firmware (again) * correct test * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * separate device test * add BT to entites * fix import * docstring * minor * fix rebase * get device from discovered devices * tweak * change tests * switch to dict * switch to options * fix * fix --------- Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: Paul Bottein <paul.bottein@gmail.com> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: tronikos <tronikos@users.noreply.github.com> Co-authored-by: Luke Lashley <conway220@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: dupondje <jean-louis@dupond.be> Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-03-21 12:08:11 +00:00
| {
CONF_MACHINE: mock_lamarzocco.serial_number,
CONF_HOST: "host",
CONF_NAME: "name",
CONF_MAC: "mac",
},
unique_id=mock_lamarzocco.serial_number,
)
entry.add_to_hass(hass)
return entry
@pytest.fixture
async def init_integration(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_lamarzocco: MagicMock
) -> MockConfigEntry:
"""Set up the LaMetric integration for testing."""
await async_init_integration(hass, mock_config_entry)
return mock_config_entry
@pytest.fixture
def device_fixture() -> LaMarzoccoModel:
"""Return the device fixture for a specific device."""
return LaMarzoccoModel.GS3_AV
@pytest.fixture
def mock_lamarzocco(
request: pytest.FixtureRequest, device_fixture: LaMarzoccoModel
) -> Generator[MagicMock, None, None]:
"""Return a mocked LM client."""
model_name = device_fixture
Add Bluetooth support to La Marzocco integration (#108287) * init * init tests * linting * checks * tests, linting * pylint * add tests * switch tests * add water heater tests * change icons * extra args cleanup * moar tests * services tests * remove extra platforms * test for unique id * back to single instance * add diagnostics * remove extra platforms * test for unique id * back to single instance * Add better connection management for Idasen Desk (#102135) * Return 'None' for light attributes when off instead of removing them (#101946) * Bump home-assistant-bluetooth to 1.10.4 (#102268) * Bump orjson to 3.9.9 (#102267) * Bump opower to 0.0.37 (#102265) * Bump Python-Roborock to 0.35.0 (#102275) * Add CodeQL CI Job (#102273) * Remove unused dsmr sensors (#102223) * rebase messed up conftest * more tests for init * add client to coveragerc * add client to coveragerc * next lmcloud version * strict typing * more typing * allow multiple machines * remove unneeded var * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/diagnostics.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * PR suggestions * remove base exception * Update manifest.json * update lmcloud * update lmcloud * remove ignore * selection bugfix for machines with space in name * bugfix temps * add options flow * send out full user input * remove options flow * split the tests to avoid timeouts * use selectoptionsdict for selection * removing rccoleman * improve test coverage to 100% * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * autoselect cloud machine for discovered machine * move default values to 3rd party lib * bring property changes from lmcloud * moving things to lmcloud * move validation to method * move more things to lmcloud * remove unused const * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * remove callback from coordinator * remove waterheater, add switch * improvement to background task * next lmcloud * adapt to lib changes * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * requested changes * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * some requested changes * changes * requested changes * move steam boiler to controls * fix: remove entities from GS3MP model + tests * remove dataclass decorator * next lmcloud version * improvements * move reauth to user step * improve config flow * remove asserts in favor of runtimeerrors * undo conftest comment * make duc return none * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * remove diagnostics, changes * refine config flow * remove runtimeerrors in favor of asserts * move initialization of lm_client to coordinator * remove things from lmclient * remove lm_client * remove lm_client * bump lm version * correctly set initialized for tests * move exception handling inside init + tests * add test for switch without bluetooth on * bump lmcloud * pass httpx client to LMLocalAPI * add call function to reduce code * switch to snapshot testing * remove bluetooth * bump version * cleanup import * remove unused const * set correct integration_type * correct default selection in CF * reduce unnecessary tests by fixture change * use other json loads helpers * move prebrew/infusion to select entity * bump lmcloud * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * requested feedback * step description, bump lmcloud * create init integration functino * revert * ruff * remove leftover BT test * make main switch main entity * bump lmcloud * re-add bluetooth * improve * bump firmware (again) * correct test * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * separate device test * add BT to entites * fix import * docstring * minor * fix rebase * get device from discovered devices * tweak * change tests * switch to dict * switch to options * fix * fix --------- Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: Paul Bottein <paul.bottein@gmail.com> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: tronikos <tronikos@users.noreply.github.com> Co-authored-by: Luke Lashley <conway220@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: dupondje <jean-louis@dupond.be> Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-03-21 12:08:11 +00:00
(serial_number, true_model_name) = MODEL_DICT[model_name]
with (
patch(
"homeassistant.components.lamarzocco.coordinator.LaMarzoccoClient",
autospec=True,
) as lamarzocco_mock,
patch(
"homeassistant.components.lamarzocco.config_flow.LaMarzoccoClient",
new=lamarzocco_mock,
),
):
lamarzocco = lamarzocco_mock.return_value
lamarzocco.machine_info = {
"machine_name": serial_number,
"serial_number": serial_number,
}
lamarzocco.model_name = model_name
lamarzocco.true_model_name = true_model_name
lamarzocco.machine_name = serial_number
lamarzocco.serial_number = serial_number
lamarzocco.firmware_version = "1.1"
lamarzocco.latest_firmware_version = "1.2"
lamarzocco.gateway_version = "v2.2-rc0"
lamarzocco.latest_gateway_version = "v3.1-rc4"
lamarzocco.update_firmware.return_value = True
lamarzocco.current_status = load_json_object_fixture(
"current_status.json", DOMAIN
)
lamarzocco.config = load_json_object_fixture("config.json", DOMAIN)
lamarzocco.statistics = load_json_array_fixture("statistics.json", DOMAIN)
lamarzocco.schedule = load_json_array_fixture("schedule.json", DOMAIN)
lamarzocco.get_all_machines.return_value = [
(serial_number, model_name),
]
lamarzocco.check_local_connection.return_value = True
lamarzocco.initialized = False
lamarzocco.websocket_connected = True
async def websocket_connect_mock(
callback: MagicMock, use_sigterm_handler: MagicMock
) -> None:
"""Mock the websocket connect method."""
return None
lamarzocco.lm_local_api.websocket_connect = websocket_connect_mock
Add Bluetooth support to La Marzocco integration (#108287) * init * init tests * linting * checks * tests, linting * pylint * add tests * switch tests * add water heater tests * change icons * extra args cleanup * moar tests * services tests * remove extra platforms * test for unique id * back to single instance * add diagnostics * remove extra platforms * test for unique id * back to single instance * Add better connection management for Idasen Desk (#102135) * Return 'None' for light attributes when off instead of removing them (#101946) * Bump home-assistant-bluetooth to 1.10.4 (#102268) * Bump orjson to 3.9.9 (#102267) * Bump opower to 0.0.37 (#102265) * Bump Python-Roborock to 0.35.0 (#102275) * Add CodeQL CI Job (#102273) * Remove unused dsmr sensors (#102223) * rebase messed up conftest * more tests for init * add client to coveragerc * add client to coveragerc * next lmcloud version * strict typing * more typing * allow multiple machines * remove unneeded var * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/diagnostics.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * PR suggestions * remove base exception * Update manifest.json * update lmcloud * update lmcloud * remove ignore * selection bugfix for machines with space in name * bugfix temps * add options flow * send out full user input * remove options flow * split the tests to avoid timeouts * use selectoptionsdict for selection * removing rccoleman * improve test coverage to 100% * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * autoselect cloud machine for discovered machine * move default values to 3rd party lib * bring property changes from lmcloud * moving things to lmcloud * move validation to method * move more things to lmcloud * remove unused const * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * remove callback from coordinator * remove waterheater, add switch * improvement to background task * next lmcloud * adapt to lib changes * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * requested changes * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * some requested changes * changes * requested changes * move steam boiler to controls * fix: remove entities from GS3MP model + tests * remove dataclass decorator * next lmcloud version * improvements * move reauth to user step * improve config flow * remove asserts in favor of runtimeerrors * undo conftest comment * make duc return none * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * remove diagnostics, changes * refine config flow * remove runtimeerrors in favor of asserts * move initialization of lm_client to coordinator * remove things from lmclient * remove lm_client * remove lm_client * bump lm version * correctly set initialized for tests * move exception handling inside init + tests * add test for switch without bluetooth on * bump lmcloud * pass httpx client to LMLocalAPI * add call function to reduce code * switch to snapshot testing * remove bluetooth * bump version * cleanup import * remove unused const * set correct integration_type * correct default selection in CF * reduce unnecessary tests by fixture change * use other json loads helpers * move prebrew/infusion to select entity * bump lmcloud * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * requested feedback * step description, bump lmcloud * create init integration functino * revert * ruff * remove leftover BT test * make main switch main entity * bump lmcloud * re-add bluetooth * improve * bump firmware (again) * correct test * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * separate device test * add BT to entites * fix import * docstring * minor * fix rebase * get device from discovered devices * tweak * change tests * switch to dict * switch to options * fix * fix --------- Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: Paul Bottein <paul.bottein@gmail.com> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: tronikos <tronikos@users.noreply.github.com> Co-authored-by: Luke Lashley <conway220@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: dupondje <jean-louis@dupond.be> Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-03-21 12:08:11 +00:00
lamarzocco.lm_bluetooth = MagicMock()
lamarzocco.lm_bluetooth.address = "AA:BB:CC:DD:EE:FF"
yield lamarzocco
@pytest.fixture
def remove_local_connection(
hass: HomeAssistant, mock_config_entry: MockConfigEntry
) -> MockConfigEntry:
"""Remove the local connection."""
data = mock_config_entry.data.copy()
del data[CONF_HOST]
hass.config_entries.async_update_entry(mock_config_entry, data=data)
return mock_config_entry
Add Bluetooth support to La Marzocco integration (#108287) * init * init tests * linting * checks * tests, linting * pylint * add tests * switch tests * add water heater tests * change icons * extra args cleanup * moar tests * services tests * remove extra platforms * test for unique id * back to single instance * add diagnostics * remove extra platforms * test for unique id * back to single instance * Add better connection management for Idasen Desk (#102135) * Return 'None' for light attributes when off instead of removing them (#101946) * Bump home-assistant-bluetooth to 1.10.4 (#102268) * Bump orjson to 3.9.9 (#102267) * Bump opower to 0.0.37 (#102265) * Bump Python-Roborock to 0.35.0 (#102275) * Add CodeQL CI Job (#102273) * Remove unused dsmr sensors (#102223) * rebase messed up conftest * more tests for init * add client to coveragerc * add client to coveragerc * next lmcloud version * strict typing * more typing * allow multiple machines * remove unneeded var * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/diagnostics.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * PR suggestions * remove base exception * Update manifest.json * update lmcloud * update lmcloud * remove ignore * selection bugfix for machines with space in name * bugfix temps * add options flow * send out full user input * remove options flow * split the tests to avoid timeouts * use selectoptionsdict for selection * removing rccoleman * improve test coverage to 100% * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * autoselect cloud machine for discovered machine * move default values to 3rd party lib * bring property changes from lmcloud * moving things to lmcloud * move validation to method * move more things to lmcloud * remove unused const * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/__init__.py Co-authored-by: Robert Resch <robert@resch.dev> * remove callback from coordinator * remove waterheater, add switch * improvement to background task * next lmcloud * adapt to lib changes * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Robert Resch <robert@resch.dev> * requested changes * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Robert Resch <robert@resch.dev> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * Update tests/components/lamarzocco/test_config_flow.py Co-authored-by: Robert Resch <robert@resch.dev> * some requested changes * changes * requested changes * move steam boiler to controls * fix: remove entities from GS3MP model + tests * remove dataclass decorator * next lmcloud version * improvements * move reauth to user step * improve config flow * remove asserts in favor of runtimeerrors * undo conftest comment * make duc return none * Update homeassistant/components/lamarzocco/switch.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/config_flow.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * remove diagnostics, changes * refine config flow * remove runtimeerrors in favor of asserts * move initialization of lm_client to coordinator * remove things from lmclient * remove lm_client * remove lm_client * bump lm version * correctly set initialized for tests * move exception handling inside init + tests * add test for switch without bluetooth on * bump lmcloud * pass httpx client to LMLocalAPI * add call function to reduce code * switch to snapshot testing * remove bluetooth * bump version * cleanup import * remove unused const * set correct integration_type * correct default selection in CF * reduce unnecessary tests by fixture change * use other json loads helpers * move prebrew/infusion to select entity * bump lmcloud * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * requested feedback * step description, bump lmcloud * create init integration functino * revert * ruff * remove leftover BT test * make main switch main entity * bump lmcloud * re-add bluetooth * improve * bump firmware (again) * correct test * Update homeassistant/components/lamarzocco/coordinator.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/entity.py Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * Update homeassistant/components/lamarzocco/strings.json Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com> * separate device test * add BT to entites * fix import * docstring * minor * fix rebase * get device from discovered devices * tweak * change tests * switch to dict * switch to options * fix * fix --------- Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com> Co-authored-by: Paul Bottein <paul.bottein@gmail.com> Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: tronikos <tronikos@users.noreply.github.com> Co-authored-by: Luke Lashley <conway220@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: dupondje <jean-louis@dupond.be> Co-authored-by: Robert Resch <robert@resch.dev> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
2024-03-21 12:08:11 +00:00
@pytest.fixture(autouse=True)
def mock_bluetooth(enable_bluetooth):
"""Auto mock bluetooth."""