Cleanup lamarzocco tests (#134383)
parent
809629c0e2
commit
7ab2d2e07a
|
@ -1,19 +1,5 @@
|
|||
# serializer version: 1
|
||||
# name: test_binary_sensors[GS012345_backflush_active-binary_sensor]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'running',
|
||||
'friendly_name': 'GS012345 Backflush active',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.gs012345_backflush_active',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_binary_sensors[GS012345_backflush_active-entry]
|
||||
# name: test_binary_sensors[binary_sensor.gs012345_backflush_active-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -46,21 +32,21 @@
|
|||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_binary_sensors[GS012345_brewing_active-binary_sensor]
|
||||
# name: test_binary_sensors[binary_sensor.gs012345_backflush_active-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'running',
|
||||
'friendly_name': 'GS012345 Brewing active',
|
||||
'friendly_name': 'GS012345 Backflush active',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.gs012345_brewing_active',
|
||||
'entity_id': 'binary_sensor.gs012345_backflush_active',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_binary_sensors[GS012345_brewing_active-entry]
|
||||
# name: test_binary_sensors[binary_sensor.gs012345_brewing_active-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -93,21 +79,21 @@
|
|||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_binary_sensors[GS012345_water_tank_empty-binary_sensor]
|
||||
# name: test_binary_sensors[binary_sensor.gs012345_brewing_active-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'problem',
|
||||
'friendly_name': 'GS012345 Water tank empty',
|
||||
'device_class': 'running',
|
||||
'friendly_name': 'GS012345 Brewing active',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.gs012345_water_tank_empty',
|
||||
'entity_id': 'binary_sensor.gs012345_brewing_active',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_binary_sensors[GS012345_water_tank_empty-entry]
|
||||
# name: test_binary_sensors[binary_sensor.gs012345_water_tank_empty-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -140,6 +126,20 @@
|
|||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_binary_sensors[binary_sensor.gs012345_water_tank_empty-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'problem',
|
||||
'friendly_name': 'GS012345 Water tank empty',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.gs012345_water_tank_empty',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_scale_connectivity[Linea Mini]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
'unit_of_measurement': '%',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_current_coffee_temperature-entry]
|
||||
# name: test_sensors[sensor.gs012345_current_coffee_temperature-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -88,7 +88,7 @@
|
|||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_current_coffee_temperature-sensor]
|
||||
# name: test_sensors[sensor.gs012345_current_coffee_temperature-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'temperature',
|
||||
|
@ -104,7 +104,7 @@
|
|||
'state': '96.5',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_current_steam_temperature-entry]
|
||||
# name: test_sensors[sensor.gs012345_current_steam_temperature-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -142,7 +142,7 @@
|
|||
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_current_steam_temperature-sensor]
|
||||
# name: test_sensors[sensor.gs012345_current_steam_temperature-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'temperature',
|
||||
|
@ -158,7 +158,7 @@
|
|||
'state': '123.800003051758',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_shot_timer-entry]
|
||||
# name: test_sensors[sensor.gs012345_shot_timer-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -193,7 +193,7 @@
|
|||
'unit_of_measurement': <UnitOfTime.SECONDS: 's'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_shot_timer-sensor]
|
||||
# name: test_sensors[sensor.gs012345_shot_timer-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'duration',
|
||||
|
@ -209,7 +209,7 @@
|
|||
'state': '0',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_total_coffees_made-entry]
|
||||
# name: test_sensors[sensor.gs012345_total_coffees_made-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -244,7 +244,7 @@
|
|||
'unit_of_measurement': 'drinks',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_total_coffees_made-sensor]
|
||||
# name: test_sensors[sensor.gs012345_total_coffees_made-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'GS012345 Total coffees made',
|
||||
|
@ -259,7 +259,7 @@
|
|||
'state': '1047',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_total_flushes_made-entry]
|
||||
# name: test_sensors[sensor.gs012345_total_flushes_made-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -294,7 +294,7 @@
|
|||
'unit_of_measurement': 'drinks',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[GS012345_total_flushes_made-sensor]
|
||||
# name: test_sensors[sensor.gs012345_total_flushes_made-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'GS012345 Total flushes made',
|
||||
|
|
|
@ -91,20 +91,7 @@
|
|||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[-set_power-kwargs0]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'GS012345',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.gs012345',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[-set_power-kwargs0].1
|
||||
# name: test_switches[switch.gs012345-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -137,20 +124,112 @@
|
|||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[_smart_standby_enabled-set_smart_standby-kwargs2]
|
||||
# name: test_switches[switch.gs012345-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'GS012345 Smart standby enabled',
|
||||
'friendly_name': 'GS012345',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.gs012345_smart_standby_enabled',
|
||||
'entity_id': 'switch.gs012345',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[_smart_standby_enabled-set_smart_standby-kwargs2].1
|
||||
# name: test_switches[switch.gs012345_auto_on_off_axfz5bj-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.gs012345_auto_on_off_axfz5bj',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Auto on/off (aXFz5bJ)',
|
||||
'platform': 'lamarzocco',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'auto_on_off',
|
||||
'unique_id': 'GS012345_auto_on_off_aXFz5bJ',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[switch.gs012345_auto_on_off_axfz5bj-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'GS012345 Auto on/off (aXFz5bJ)',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.gs012345_auto_on_off_axfz5bj',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[switch.gs012345_auto_on_off_os2oswx-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.gs012345_auto_on_off_os2oswx',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Auto on/off (Os2OswX)',
|
||||
'platform': 'lamarzocco',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'auto_on_off',
|
||||
'unique_id': 'GS012345_auto_on_off_Os2OswX',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[switch.gs012345_auto_on_off_os2oswx-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'GS012345 Auto on/off (Os2OswX)',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.gs012345_auto_on_off_os2oswx',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[switch.gs012345_smart_standby_enabled-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -183,20 +262,20 @@
|
|||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[_steam_boiler-set_steam-kwargs1]
|
||||
# name: test_switches[switch.gs012345_smart_standby_enabled-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'GS012345 Steam boiler',
|
||||
'friendly_name': 'GS012345 Smart standby enabled',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.gs012345_steam_boiler',
|
||||
'entity_id': 'switch.gs012345_smart_standby_enabled',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[_steam_boiler-set_steam-kwargs1].1
|
||||
# name: test_switches[switch.gs012345_steam_boiler-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -229,3 +308,16 @@
|
|||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switches[switch.gs012345_steam_boiler-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'GS012345 Steam boiler',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.gs012345_steam_boiler',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
|
|
|
@ -1,31 +1,5 @@
|
|||
# serializer version: 1
|
||||
# name: test_update_entites[gateway_firmware-gateway]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'auto_update': False,
|
||||
'device_class': 'firmware',
|
||||
'display_precision': 0,
|
||||
'entity_picture': 'https://brands.home-assistant.io/_/lamarzocco/icon.png',
|
||||
'friendly_name': 'GS012345 Gateway firmware',
|
||||
'in_progress': False,
|
||||
'installed_version': 'v3.1-rc4',
|
||||
'latest_version': 'v3.5-rc3',
|
||||
'release_summary': None,
|
||||
'release_url': 'https://support-iot.lamarzocco.com/firmware-updates/',
|
||||
'skipped_version': None,
|
||||
'supported_features': <UpdateEntityFeature: 1>,
|
||||
'title': None,
|
||||
'update_percentage': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'update.gs012345_gateway_firmware',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_update_entites[gateway_firmware-gateway].1
|
||||
# name: test_update[update.gs012345_gateway_firmware-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -58,17 +32,17 @@
|
|||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_update_entites[machine_firmware-machine]
|
||||
# name: test_update[update.gs012345_gateway_firmware-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'auto_update': False,
|
||||
'device_class': 'firmware',
|
||||
'display_precision': 0,
|
||||
'entity_picture': 'https://brands.home-assistant.io/_/lamarzocco/icon.png',
|
||||
'friendly_name': 'GS012345 Machine firmware',
|
||||
'friendly_name': 'GS012345 Gateway firmware',
|
||||
'in_progress': False,
|
||||
'installed_version': '1.40',
|
||||
'latest_version': '1.55',
|
||||
'installed_version': 'v3.1-rc4',
|
||||
'latest_version': 'v3.5-rc3',
|
||||
'release_summary': None,
|
||||
'release_url': 'https://support-iot.lamarzocco.com/firmware-updates/',
|
||||
'skipped_version': None,
|
||||
|
@ -77,14 +51,14 @@
|
|||
'update_percentage': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'update.gs012345_machine_firmware',
|
||||
'entity_id': 'update.gs012345_gateway_firmware',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_update_entites[machine_firmware-machine].1
|
||||
# name: test_update[update.gs012345_machine_firmware-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
|
@ -117,3 +91,29 @@
|
|||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_update[update.gs012345_machine_firmware-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'auto_update': False,
|
||||
'device_class': 'firmware',
|
||||
'display_precision': 0,
|
||||
'entity_picture': 'https://brands.home-assistant.io/_/lamarzocco/icon.png',
|
||||
'friendly_name': 'GS012345 Machine firmware',
|
||||
'in_progress': False,
|
||||
'installed_version': '1.40',
|
||||
'latest_version': '1.55',
|
||||
'release_summary': None,
|
||||
'release_url': 'https://support-iot.lamarzocco.com/firmware-updates/',
|
||||
'skipped_version': None,
|
||||
'supported_features': <UpdateEntityFeature: 1>,
|
||||
'title': None,
|
||||
'update_percentage': None,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'update.gs012345_machine_firmware',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for La Marzocco binary sensors."""
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from pylamarzocco.const import MachineModel
|
||||
|
@ -10,19 +10,13 @@ from pylamarzocco.models import LaMarzoccoScale
|
|||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.const import STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import async_init_integration
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
BINARY_SENSORS = (
|
||||
"brewing_active",
|
||||
"backflush_active",
|
||||
"water_tank_empty",
|
||||
)
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||
|
||||
|
||||
async def test_binary_sensors(
|
||||
|
@ -34,19 +28,11 @@ async def test_binary_sensors(
|
|||
) -> None:
|
||||
"""Test the La Marzocco binary sensors."""
|
||||
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
|
||||
serial_number = mock_lamarzocco.serial_number
|
||||
|
||||
for binary_sensor in BINARY_SENSORS:
|
||||
state = hass.states.get(f"binary_sensor.{serial_number}_{binary_sensor}")
|
||||
assert state
|
||||
assert state == snapshot(name=f"{serial_number}_{binary_sensor}-binary_sensor")
|
||||
|
||||
entry = entity_registry.async_get(state.entity_id)
|
||||
assert entry
|
||||
assert entry.device_id
|
||||
assert entry == snapshot(name=f"{serial_number}_{binary_sensor}-entry")
|
||||
with patch(
|
||||
"homeassistant.components.lamarzocco.PLATFORMS", [Platform.BINARY_SENSOR]
|
||||
):
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_brew_active_does_not_exists(
|
||||
|
|
|
@ -38,9 +38,7 @@ async def test_load_unload_config_entry(
|
|||
mock_lamarzocco: MagicMock,
|
||||
) -> None:
|
||||
"""Test loading and unloading the integration."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
|
@ -58,9 +56,7 @@ async def test_config_entry_not_ready(
|
|||
"""Test the La Marzocco configuration entry not ready."""
|
||||
mock_lamarzocco.get_config.side_effect = RequestNotSuccessful("")
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
|
||||
assert len(mock_lamarzocco.get_config.mock_calls) == 1
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
@ -73,9 +69,7 @@ async def test_invalid_auth(
|
|||
) -> None:
|
||||
"""Test auth error during setup."""
|
||||
mock_lamarzocco.get_config.side_effect = AuthFail("")
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.SETUP_ERROR
|
||||
assert len(mock_lamarzocco.get_config.mock_calls) == 1
|
||||
|
|
|
@ -30,6 +30,8 @@ from . import async_init_integration
|
|||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
pytest.mark.usefixtures("init_integration")
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_integration")
|
||||
@pytest.mark.parametrize("device_fixture", [MachineModel.LINEA_MICRA])
|
||||
|
@ -66,9 +68,6 @@ async def test_steam_boiler_level(
|
|||
mock_lamarzocco.set_steam_level.assert_called_once_with(level=SteamLevel.LEVEL_2)
|
||||
|
||||
|
||||
pytest.mark.usefixtures("init_integration")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"device_fixture",
|
||||
[MachineModel.GS3_AV, MachineModel.GS3_MP, MachineModel.LINEA_MINI],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for La Marzocco sensors."""
|
||||
|
||||
from datetime import timedelta
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from pylamarzocco.const import MachineModel
|
||||
|
@ -9,21 +9,13 @@ from pylamarzocco.models import LaMarzoccoScale
|
|||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.const import STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import async_init_integration
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
SENSORS = (
|
||||
"total_coffees_made",
|
||||
"total_flushes_made",
|
||||
"shot_timer",
|
||||
"current_coffee_temperature",
|
||||
"current_steam_temperature",
|
||||
)
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform
|
||||
|
||||
|
||||
async def test_sensors(
|
||||
|
@ -35,19 +27,9 @@ async def test_sensors(
|
|||
) -> None:
|
||||
"""Test the La Marzocco sensors."""
|
||||
|
||||
serial_number = mock_lamarzocco.serial_number
|
||||
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
|
||||
for sensor in SENSORS:
|
||||
state = hass.states.get(f"sensor.{serial_number}_{sensor}")
|
||||
assert state
|
||||
assert state == snapshot(name=f"{serial_number}_{sensor}-sensor")
|
||||
|
||||
entry = entity_registry.async_get(state.entity_id)
|
||||
assert entry
|
||||
assert entry.device_id
|
||||
assert entry == snapshot(name=f"{serial_number}_{sensor}-entry")
|
||||
with patch("homeassistant.components.lamarzocco.PLATFORMS", [Platform.SENSOR]):
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
async def test_shot_timer_not_exists(
|
||||
|
@ -102,6 +84,7 @@ async def test_scale_battery(
|
|||
await async_init_integration(hass, mock_config_entry)
|
||||
|
||||
state = hass.states.get("sensor.lmz_123a45_battery")
|
||||
assert state
|
||||
assert state == snapshot
|
||||
|
||||
entry = entity_registry.async_get(state.entity_id)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Tests for La Marzocco switches."""
|
||||
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from pylamarzocco.exceptions import RequestNotSuccessful
|
||||
import pytest
|
||||
|
@ -12,14 +12,27 @@ from homeassistant.components.switch import (
|
|||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import WAKE_UP_SLEEP_ENTRY_IDS, async_init_integration
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
async def test_switches(
|
||||
hass: HomeAssistant,
|
||||
mock_lamarzocco: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test the La Marzocco switches."""
|
||||
with patch("homeassistant.components.lamarzocco.PLATFORMS", [Platform.SWITCH]):
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -38,12 +51,10 @@ from tests.common import MockConfigEntry
|
|||
),
|
||||
],
|
||||
)
|
||||
async def test_switches(
|
||||
async def test_switches_actions(
|
||||
hass: HomeAssistant,
|
||||
mock_lamarzocco: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
entity_name: str,
|
||||
method_name: str,
|
||||
kwargs: dict[str, Any],
|
||||
|
@ -55,14 +66,6 @@ async def test_switches(
|
|||
|
||||
control_fn = getattr(mock_lamarzocco, method_name)
|
||||
|
||||
state = hass.states.get(f"switch.{serial_number}{entity_name}")
|
||||
assert state
|
||||
assert state == snapshot
|
||||
|
||||
entry = entity_registry.async_get(state.entity_id)
|
||||
assert entry
|
||||
assert entry == snapshot
|
||||
|
||||
await hass.services.async_call(
|
||||
SWITCH_DOMAIN,
|
||||
SERVICE_TURN_OFF,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Tests for the La Marzocco Update Entities."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from pylamarzocco.const import FirmwareType
|
||||
from pylamarzocco.exceptions import RequestNotSuccessful
|
||||
|
@ -8,12 +8,27 @@ import pytest
|
|||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.update import DOMAIN as UPDATE_DOMAIN, SERVICE_INSTALL
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("init_integration")
|
||||
from . import async_init_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
async def test_update(
|
||||
hass: HomeAssistant,
|
||||
mock_lamarzocco: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test the La Marzocco updates."""
|
||||
with patch("homeassistant.components.lamarzocco.PLATFORMS", [Platform.UPDATE]):
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -26,8 +41,7 @@ pytestmark = pytest.mark.usefixtures("init_integration")
|
|||
async def test_update_entites(
|
||||
hass: HomeAssistant,
|
||||
mock_lamarzocco: MagicMock,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_name: str,
|
||||
component: FirmwareType,
|
||||
) -> None:
|
||||
|
@ -35,13 +49,7 @@ async def test_update_entites(
|
|||
|
||||
serial_number = mock_lamarzocco.serial_number
|
||||
|
||||
state = hass.states.get(f"update.{serial_number}_{entity_name}")
|
||||
assert state
|
||||
assert state == snapshot
|
||||
|
||||
entry = entity_registry.async_get(state.entity_id)
|
||||
assert entry
|
||||
assert entry == snapshot
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
|
||||
await hass.services.async_call(
|
||||
UPDATE_DOMAIN,
|
||||
|
@ -65,10 +73,14 @@ async def test_update_entites(
|
|||
async def test_update_error(
|
||||
hass: HomeAssistant,
|
||||
mock_lamarzocco: MagicMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
attr: str,
|
||||
value: bool | Exception,
|
||||
) -> None:
|
||||
"""Test error during update."""
|
||||
|
||||
await async_init_integration(hass, mock_config_entry)
|
||||
|
||||
state = hass.states.get(f"update.{mock_lamarzocco.serial_number}_machine_firmware")
|
||||
assert state
|
||||
|
||||
|
|
Loading…
Reference in New Issue