Check for uncaught service not found exceptions (#58010)
This commit is contained in:
parent
0e19278309
commit
f51e1fcb67
8 changed files with 84 additions and 49 deletions
|
@ -310,13 +310,6 @@ async def test_skipfirst(hass):
|
|||
assert len(events) == 0
|
||||
|
||||
|
||||
async def test_noack(hass):
|
||||
"""Test no ack feature."""
|
||||
entity = alert.Alert(hass, *TEST_NOACK)
|
||||
hass.async_add_job(entity.begin_alerting)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_done_message_state_tracker_reset_on_cancel(hass):
|
||||
"""Test that the done message is reset when canceled."""
|
||||
entity = alert.Alert(hass, *TEST_NOACK)
|
||||
|
|
|
@ -7,7 +7,7 @@ import pytest
|
|||
|
||||
@pytest.fixture(autouse=True)
|
||||
def stub_blueprint_populate():
|
||||
"""Stub copying the blueprint automations to the config folder."""
|
||||
"""Stub copying the blueprints to the config folder."""
|
||||
with patch(
|
||||
"homeassistant.components.blueprint.models.DomainBlueprints.async_populate"
|
||||
):
|
||||
|
|
|
@ -3,6 +3,8 @@ from http import HTTPStatus
|
|||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components import config
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
@ -10,7 +12,18 @@ from homeassistant.helpers import entity_registry as er
|
|||
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa: F401
|
||||
|
||||
|
||||
async def test_get_device_config(hass, hass_client):
|
||||
@pytest.fixture
|
||||
async def setup_automation(
|
||||
hass, automation_config, stub_blueprint_populate # noqa: F811
|
||||
):
|
||||
"""Set up automation integration."""
|
||||
assert await async_setup_component(
|
||||
hass, "automation", {"automation": automation_config}
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("automation_config", ({},))
|
||||
async def test_get_device_config(hass, hass_client, setup_automation):
|
||||
"""Test getting device config."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
@ -30,7 +43,8 @@ async def test_get_device_config(hass, hass_client):
|
|||
assert result == {"id": "moon"}
|
||||
|
||||
|
||||
async def test_update_device_config(hass, hass_client):
|
||||
@pytest.mark.parametrize("automation_config", ({},))
|
||||
async def test_update_device_config(hass, hass_client, setup_automation):
|
||||
"""Test updating device config."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
@ -66,7 +80,8 @@ async def test_update_device_config(hass, hass_client):
|
|||
assert written[0] == orig_data
|
||||
|
||||
|
||||
async def test_bad_formatted_automations(hass, hass_client):
|
||||
@pytest.mark.parametrize("automation_config", ({},))
|
||||
async def test_bad_formatted_automations(hass, hass_client, setup_automation):
|
||||
"""Test that we handle automations without ID."""
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
@ -110,29 +125,27 @@ async def test_bad_formatted_automations(hass, hass_client):
|
|||
assert orig_data[1] == {"id": "moon", "trigger": [], "condition": [], "action": []}
|
||||
|
||||
|
||||
async def test_delete_automation(hass, hass_client):
|
||||
@pytest.mark.parametrize(
|
||||
"automation_config",
|
||||
(
|
||||
[
|
||||
{
|
||||
"id": "sun",
|
||||
"trigger": {"platform": "event", "event_type": "test_event"},
|
||||
"action": {"service": "test.automation"},
|
||||
},
|
||||
{
|
||||
"id": "moon",
|
||||
"trigger": {"platform": "event", "event_type": "test_event"},
|
||||
"action": {"service": "test.automation"},
|
||||
},
|
||||
],
|
||||
),
|
||||
)
|
||||
async def test_delete_automation(hass, hass_client, setup_automation):
|
||||
"""Test deleting an automation."""
|
||||
ent_reg = er.async_get(hass)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
"automation",
|
||||
{
|
||||
"automation": [
|
||||
{
|
||||
"id": "sun",
|
||||
"trigger": {"platform": "event", "event_type": "test_event"},
|
||||
"action": {"service": "test.automation"},
|
||||
},
|
||||
{
|
||||
"id": "moon",
|
||||
"trigger": {"platform": "event", "event_type": "test_event"},
|
||||
"action": {"service": "test.automation"},
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
assert len(ent_reg.entities) == 2
|
||||
|
||||
with patch.object(config, "SECTIONS", ["automation"]):
|
||||
|
|
|
@ -3,11 +3,19 @@ from http import HTTPStatus
|
|||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components import config
|
||||
from homeassistant.config import DATA_CUSTOMIZE
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
async def setup_homeassistant(hass):
|
||||
"""Set up homeassistant integration."""
|
||||
assert await async_setup_component(hass, "homeassistant", {})
|
||||
|
||||
|
||||
async def test_get_entity(hass, hass_client):
|
||||
"""Test getting entity."""
|
||||
with patch.object(config, "SECTIONS", ["customize"]):
|
||||
|
|
|
@ -3,13 +3,22 @@ from http import HTTPStatus
|
|||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components import config
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util.yaml import dump
|
||||
|
||||
|
||||
async def test_create_scene(hass, hass_client):
|
||||
@pytest.fixture
|
||||
async def setup_scene(hass, scene_config):
|
||||
"""Set up scene integration."""
|
||||
assert await async_setup_component(hass, "scene", {"scene": scene_config})
|
||||
|
||||
|
||||
@pytest.mark.parametrize("scene_config", ({},))
|
||||
async def test_create_scene(hass, hass_client, setup_scene):
|
||||
"""Test creating a scene."""
|
||||
with patch.object(config, "SECTIONS", ["scene"]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
@ -58,7 +67,8 @@ async def test_create_scene(hass, hass_client):
|
|||
)
|
||||
|
||||
|
||||
async def test_update_scene(hass, hass_client):
|
||||
@pytest.mark.parametrize("scene_config", ({},))
|
||||
async def test_update_scene(hass, hass_client, setup_scene):
|
||||
"""Test updating a scene."""
|
||||
with patch.object(config, "SECTIONS", ["scene"]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
@ -110,7 +120,8 @@ async def test_update_scene(hass, hass_client):
|
|||
)
|
||||
|
||||
|
||||
async def test_bad_formatted_scene(hass, hass_client):
|
||||
@pytest.mark.parametrize("scene_config", ({},))
|
||||
async def test_bad_formatted_scene(hass, hass_client, setup_scene):
|
||||
"""Test that we handle scene without ID."""
|
||||
with patch.object(config, "SECTIONS", ["scene"]):
|
||||
await async_setup_component(hass, "config", {})
|
||||
|
@ -163,21 +174,19 @@ async def test_bad_formatted_scene(hass, hass_client):
|
|||
}
|
||||
|
||||
|
||||
async def test_delete_scene(hass, hass_client):
|
||||
@pytest.mark.parametrize(
|
||||
"scene_config",
|
||||
(
|
||||
[
|
||||
{"id": "light_on", "name": "Light on", "entities": {}},
|
||||
{"id": "light_off", "name": "Light off", "entities": {}},
|
||||
],
|
||||
),
|
||||
)
|
||||
async def test_delete_scene(hass, hass_client, setup_scene):
|
||||
"""Test deleting a scene."""
|
||||
ent_reg = er.async_get(hass)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
"scene",
|
||||
{
|
||||
"scene": [
|
||||
{"id": "light_on", "name": "Light on", "entities": {}},
|
||||
{"id": "light_off", "name": "Light off", "entities": {}},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
assert len(ent_reg.entities) == 2
|
||||
|
||||
with patch.object(config, "SECTIONS", ["scene"]):
|
||||
|
|
|
@ -2,9 +2,19 @@
|
|||
from http import HTTPStatus
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.bootstrap import async_setup_component
|
||||
from homeassistant.components import config
|
||||
|
||||
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa: F401
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
async def setup_script(hass, stub_blueprint_populate): # noqa: F811
|
||||
"""Set up script integration."""
|
||||
assert await async_setup_component(hass, "script", {})
|
||||
|
||||
|
||||
async def test_delete_script(hass, hass_client):
|
||||
"""Test deleting a script."""
|
||||
|
|
|
@ -312,6 +312,8 @@ async def test_fan_speed(hass, hk_driver, events):
|
|||
assert acc.char_speed.value == 50
|
||||
assert acc.char_active.value == 0
|
||||
|
||||
call_turn_on = async_mock_service(hass, DOMAIN, "turn_on")
|
||||
|
||||
hk_driver.set_characteristics(
|
||||
{
|
||||
HAP_REPR_CHARS: [
|
||||
|
@ -328,6 +330,9 @@ async def test_fan_speed(hass, hk_driver, events):
|
|||
assert acc.char_speed.value == 50
|
||||
assert acc.char_active.value == 1
|
||||
|
||||
assert call_turn_on[0]
|
||||
assert call_turn_on[0].data[ATTR_ENTITY_ID] == entity_id
|
||||
|
||||
|
||||
async def test_fan_set_all_one_shot(hass, hk_driver, events):
|
||||
"""Test fan with speed."""
|
||||
|
|
|
@ -26,7 +26,6 @@ from homeassistant.components.websocket_api.auth import (
|
|||
)
|
||||
from homeassistant.components.websocket_api.http import URL
|
||||
from homeassistant.const import ATTR_NOW, EVENT_TIME_CHANGED
|
||||
from homeassistant.exceptions import ServiceNotFound
|
||||
from homeassistant.helpers import config_entry_oauth2_flow, event
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import location
|
||||
|
@ -232,8 +231,6 @@ def hass(loop, load_registries, hass_storage, request):
|
|||
request.function.__name__,
|
||||
) in IGNORE_UNCAUGHT_EXCEPTIONS:
|
||||
continue
|
||||
if isinstance(ex, ServiceNotFound):
|
||||
continue
|
||||
raise ex
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue