1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Replace assert_lists_same with pytest_unordered in integrations h-m (#94901)

This commit is contained in:
Erik Montnemery 2023-06-20 20:16:25 +02:00 committed by GitHub
parent c4d7695173
commit fd822bce56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 61 additions and 59 deletions

View File

@ -7,6 +7,7 @@ from unittest.mock import ANY, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
from pytest_unordered import unordered
from homeassistant.components.homeassistant_alerts import (
COMPONENT_LOADED_COOLDOWN,
@ -19,7 +20,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.setup import ATTR_COMPONENT, async_setup_component
from homeassistant.util import dt as dt_util
from tests.common import assert_lists_same, async_fire_time_changed, load_fixture
from tests.common import async_fire_time_changed, load_fixture
from tests.test_util.aiohttp import AiohttpClientMocker
from tests.typing import WebSocketGenerator
@ -613,8 +614,7 @@ async def test_alerts_change(
await client.send_json({"id": 1, "type": "repairs/list_issues"})
msg = await client.receive_json()
assert msg["success"]
assert_lists_same(
msg["result"]["issues"],
assert msg["result"]["issues"] == unordered(
[
{
"breaks_in_ha_version": None,
@ -634,7 +634,7 @@ async def test_alerts_change(
},
}
for alert_id, integration in expected_alerts_1
],
]
)
fixture_2_content = load_fixture(fixture_2, "homeassistant_alerts")
@ -653,8 +653,7 @@ async def test_alerts_change(
await client.send_json({"id": 2, "type": "repairs/list_issues"})
msg = await client.receive_json()
assert msg["success"]
assert_lists_same(
msg["result"]["issues"],
assert msg["result"]["issues"] == unordered(
[
{
"breaks_in_ha_version": None,
@ -674,5 +673,5 @@ async def test_alerts_change(
},
}
for alert_id, integration in expected_alerts_2
],
]
)

View File

@ -2,6 +2,7 @@
from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -14,7 +15,6 @@ from homeassistant.setup import async_setup_component
from .common import setup_test_component
from tests.common import (
assert_lists_same,
async_get_device_automations,
async_mock_service,
)
@ -131,7 +131,7 @@ async def test_enumerate_remote(hass: HomeAssistant, utcnow) -> None:
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device.id
)
assert_lists_same(triggers, expected)
assert triggers == unordered(expected)
async def test_enumerate_button(hass: HomeAssistant, utcnow) -> None:
@ -178,7 +178,7 @@ async def test_enumerate_button(hass: HomeAssistant, utcnow) -> None:
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device.id
)
assert_lists_same(triggers, expected)
assert triggers == unordered(expected)
async def test_enumerate_doorbell(hass: HomeAssistant, utcnow) -> None:
@ -225,7 +225,7 @@ async def test_enumerate_doorbell(hass: HomeAssistant, utcnow) -> None:
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device.id
)
assert_lists_same(triggers, expected)
assert triggers == unordered(expected)
async def test_handle_events(hass: HomeAssistant, utcnow, calls) -> None:

View File

@ -1,4 +1,6 @@
"""The tests for Philips Hue device triggers for V1 bridge."""
from pytest_unordered import unordered
from homeassistant.components import automation, hue
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.hue.v1 import device_trigger
@ -8,7 +10,7 @@ from homeassistant.setup import async_setup_component
from .conftest import setup_platform
from .test_sensor_v1 import HUE_DIMMER_REMOTE_1, HUE_TAP_REMOTE_1
from tests.common import assert_lists_same, async_get_device_automations
from tests.common import async_get_device_automations
REMOTES_RESPONSE = {"7": HUE_TAP_REMOTE_1, "8": HUE_DIMMER_REMOTE_1}
@ -41,7 +43,7 @@ async def test_get_triggers(hass: HomeAssistant, mock_bridge_v1, device_reg) ->
}
for t_type, t_subtype in device_trigger.HUE_TAP_REMOTE
]
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
# Get triggers for specific dimmer switch
hue_dimmer_device = device_reg.async_get_device(
@ -73,7 +75,7 @@ async def test_get_triggers(hass: HomeAssistant, mock_bridge_v1, device_reg) ->
for t_type, t_subtype in device_trigger.HUE_DIMMER_REMOTE
),
]
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_if_fires_on_state_change(

View File

@ -1,5 +1,6 @@
"""The tests for Philips Hue device triggers for V2 bridge."""
from aiohue.v2.models.button import ButtonEvent
from pytest_unordered import unordered
from homeassistant.components import hue
from homeassistant.components.device_automation import DeviceAutomationType
@ -10,7 +11,6 @@ from homeassistant.core import HomeAssistant
from .conftest import setup_platform
from tests.common import (
assert_lists_same,
async_capture_events,
async_get_device_automations,
)
@ -96,4 +96,4 @@ async def test_get_triggers(
),
]
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)

View File

@ -1,5 +1,6 @@
"""The tests for Humidifier device actions."""
import pytest
from pytest_unordered import unordered
import voluptuous_serialize
import homeassistant.components.automation as automation
@ -17,7 +18,6 @@ from homeassistant.setup import async_setup_component
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_get_device_automations,
async_mock_service,
)
@ -89,7 +89,7 @@ async def test_get_actions(
actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id
)
assert_lists_same(actions, expected_actions)
assert actions == unordered(expected_actions)
@pytest.mark.parametrize(
@ -138,7 +138,7 @@ async def test_get_actions_hidden_auxiliary(
actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id
)
assert_lists_same(actions, expected_actions)
assert actions == unordered(expected_actions)
async def test_action(hass: HomeAssistant) -> None:

View File

@ -1,5 +1,6 @@
"""The tests for Humidifier device conditions."""
import pytest
from pytest_unordered import unordered
import voluptuous_serialize
import homeassistant.components.automation as automation
@ -17,7 +18,6 @@ from homeassistant.setup import async_setup_component
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_get_device_automations,
async_mock_service,
)
@ -97,7 +97,7 @@ async def test_get_conditions(
conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id
)
assert_lists_same(conditions, expected_conditions)
assert conditions == unordered(expected_conditions)
@pytest.mark.parametrize(
@ -145,7 +145,7 @@ async def test_get_conditions_hidden_auxiliary(
conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id
)
assert_lists_same(conditions, expected_conditions)
assert conditions == unordered(expected_conditions)
async def test_if_state(hass: HomeAssistant, calls) -> None:

View File

@ -2,6 +2,7 @@
import datetime
import pytest
from pytest_unordered import unordered
import voluptuous_serialize
import homeassistant.components.automation as automation
@ -26,7 +27,6 @@ import homeassistant.util.dt as dt_util
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_fire_time_changed,
async_get_device_automations,
async_mock_service,
@ -89,7 +89,7 @@ async def test_get_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
@pytest.mark.parametrize(
@ -142,7 +142,7 @@ async def test_get_triggers_hidden_auxiliary(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_if_fires_on_state_change(hass: HomeAssistant, calls) -> None:

View File

@ -2,6 +2,7 @@
from pypck.inputs import ModSendKeysHost, ModStatusAccessControl
from pypck.lcn_addr import LcnAddr
from pypck.lcn_defs import AccessControlPeriphery, KeyAction, SendKeyCommand
from pytest_unordered import unordered
import voluptuous_serialize
from homeassistant.components import automation
@ -15,7 +16,7 @@ from homeassistant.setup import async_setup_component
from .conftest import get_device
from tests.common import assert_lists_same, async_get_device_automations
from tests.common import async_get_device_automations
async def test_get_triggers_module_device(
@ -44,7 +45,7 @@ async def test_get_triggers_module_device(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_get_triggers_non_module_device(

View File

@ -1,5 +1,6 @@
"""The test for light device automation."""
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -19,7 +20,6 @@ from homeassistant.setup import async_setup_component
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_get_device_automation_capabilities,
async_get_device_automations,
async_mock_service,
@ -78,7 +78,7 @@ async def test_get_actions(
actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id
)
assert_lists_same(actions, expected_actions)
assert actions == unordered(expected_actions)
@pytest.mark.parametrize(
@ -128,7 +128,7 @@ async def test_get_actions_hidden_auxiliary(
actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id
)
assert_lists_same(actions, expected_actions)
assert actions == unordered(expected_actions)
async def test_get_action_capabilities(

View File

@ -3,6 +3,7 @@ from datetime import timedelta
from freezegun import freeze_time
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -16,7 +17,6 @@ import homeassistant.util.dt as dt_util
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_get_device_automation_capabilities,
async_get_device_automations,
async_mock_service,
@ -111,7 +111,7 @@ async def test_get_conditions_hidden_auxiliary(
conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id
)
assert_lists_same(conditions, expected_conditions)
assert conditions == unordered(expected_conditions)
async def test_get_condition_capabilities(

View File

@ -2,6 +2,7 @@
from datetime import timedelta
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -15,7 +16,6 @@ import homeassistant.util.dt as dt_util
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_fire_time_changed,
async_get_device_automation_capabilities,
async_get_device_automations,
@ -63,7 +63,7 @@ async def test_get_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
@pytest.mark.parametrize(
@ -111,7 +111,7 @@ async def test_get_triggers_hidden_auxiliary(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_get_trigger_capabilities(

View File

@ -1,5 +1,6 @@
"""The tests for Lock device actions."""
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -12,7 +13,6 @@ from homeassistant.setup import async_setup_component
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_get_device_automations,
async_mock_service,
)
@ -84,7 +84,7 @@ async def test_get_actions(
actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id
)
assert_lists_same(actions, expected_actions)
assert actions == unordered(expected_actions)
@pytest.mark.parametrize(
@ -133,7 +133,7 @@ async def test_get_actions_hidden_auxiliary(
actions = await async_get_device_automations(
hass, DeviceAutomationType.ACTION, device_entry.id
)
assert_lists_same(actions, expected_actions)
assert actions == unordered(expected_actions)
async def test_action(hass: HomeAssistant) -> None:

View File

@ -1,5 +1,6 @@
"""The tests for Lock device conditions."""
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -19,7 +20,6 @@ from homeassistant.setup import async_setup_component
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_get_device_automations,
async_mock_service,
)
@ -71,7 +71,7 @@ async def test_get_conditions(
conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id
)
assert_lists_same(conditions, expected_conditions)
assert conditions == unordered(expected_conditions)
@pytest.mark.parametrize(
@ -125,7 +125,7 @@ async def test_get_conditions_hidden_auxiliary(
conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id
)
assert_lists_same(conditions, expected_conditions)
assert conditions == unordered(expected_conditions)
async def test_if_state(hass: HomeAssistant, calls) -> None:

View File

@ -2,6 +2,7 @@
from datetime import timedelta
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -22,7 +23,6 @@ import homeassistant.util.dt as dt_util
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_fire_time_changed,
async_get_device_automation_capabilities,
async_get_device_automations,
@ -70,7 +70,7 @@ async def test_get_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
@pytest.mark.parametrize(
@ -118,7 +118,7 @@ async def test_get_triggers_hidden_auxiliary(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_get_trigger_capabilities(

View File

@ -2,6 +2,7 @@
from unittest.mock import patch
import pytest
from pytest_unordered import unordered
from homeassistant.components import automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -39,7 +40,6 @@ from . import MockBridge
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_get_device_automations,
async_mock_service,
)
@ -165,7 +165,7 @@ async def test_get_triggers(hass: HomeAssistant) -> None:
hass, DeviceAutomationType.TRIGGER, device_id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_get_triggers_for_invalid_device_id(

View File

@ -1,5 +1,6 @@
"""The tests for Media player device conditions."""
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -20,7 +21,6 @@ from homeassistant.setup import async_setup_component
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_get_device_automations,
async_mock_service,
)
@ -73,7 +73,7 @@ async def test_get_conditions(
conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id
)
assert_lists_same(conditions, expected_conditions)
assert conditions == unordered(expected_conditions)
@pytest.mark.parametrize(
@ -128,7 +128,7 @@ async def test_get_conditions_hidden_auxiliary(
conditions = await async_get_device_automations(
hass, DeviceAutomationType.CONDITION, device_entry.id
)
assert_lists_same(conditions, expected_conditions)
assert conditions == unordered(expected_conditions)
async def test_if_state(hass: HomeAssistant, calls) -> None:

View File

@ -2,6 +2,7 @@
from datetime import timedelta
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -23,7 +24,6 @@ import homeassistant.util.dt as dt_util
from tests.common import (
MockConfigEntry,
assert_lists_same,
async_fire_time_changed,
async_get_device_automation_capabilities,
async_get_device_automations,
@ -81,7 +81,7 @@ async def test_get_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
@pytest.mark.parametrize(
@ -137,7 +137,7 @@ async def test_get_triggers_hidden_auxiliary(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_get_trigger_capabilities(

View File

@ -3,6 +3,7 @@ import json
from unittest.mock import patch
import pytest
from pytest_unordered import unordered
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
@ -17,7 +18,6 @@ from homeassistant.setup import async_setup_component
from .test_common import help_test_unload_config_entry
from tests.common import (
assert_lists_same,
async_fire_mqtt_message,
async_get_device_automations,
async_mock_service,
@ -79,7 +79,7 @@ async def test_get_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_get_unknown_triggers(
@ -126,7 +126,7 @@ async def test_get_unknown_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, [])
assert triggers == []
async def test_get_non_existing_triggers(
@ -149,7 +149,7 @@ async def test_get_non_existing_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, [])
assert triggers == []
@pytest.mark.no_fail_on_log_exception
@ -200,7 +200,7 @@ async def test_discover_bad_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers)
assert triggers == unordered(expected_triggers)
async def test_update_remove_triggers(
@ -253,7 +253,7 @@ async def test_update_remove_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers1)
assert triggers == unordered(expected_triggers1)
# Update trigger
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla/config", data2)
@ -262,7 +262,7 @@ async def test_update_remove_triggers(
triggers = await async_get_device_automations(
hass, DeviceAutomationType.TRIGGER, device_entry.id
)
assert_lists_same(triggers, expected_triggers2)
assert triggers == unordered(expected_triggers2)
# Remove trigger
async_fire_mqtt_message(hass, "homeassistant/device_automation/bla/config", "")