mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Check for uncaught service not found exceptions (#58010)
This commit is contained in:
parent
0e19278309
commit
f51e1fcb67
@ -310,13 +310,6 @@ async def test_skipfirst(hass):
|
|||||||
assert len(events) == 0
|
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):
|
async def test_done_message_state_tracker_reset_on_cancel(hass):
|
||||||
"""Test that the done message is reset when canceled."""
|
"""Test that the done message is reset when canceled."""
|
||||||
entity = alert.Alert(hass, *TEST_NOACK)
|
entity = alert.Alert(hass, *TEST_NOACK)
|
||||||
|
@ -7,7 +7,7 @@ import pytest
|
|||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def stub_blueprint_populate():
|
def stub_blueprint_populate():
|
||||||
"""Stub copying the blueprint automations to the config folder."""
|
"""Stub copying the blueprints to the config folder."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.blueprint.models.DomainBlueprints.async_populate"
|
"homeassistant.components.blueprint.models.DomainBlueprints.async_populate"
|
||||||
):
|
):
|
||||||
|
@ -3,6 +3,8 @@ from http import HTTPStatus
|
|||||||
import json
|
import json
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
from homeassistant.components import config
|
from homeassistant.components import config
|
||||||
from homeassistant.helpers import entity_registry as er
|
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
|
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."""
|
"""Test getting device config."""
|
||||||
with patch.object(config, "SECTIONS", ["automation"]):
|
with patch.object(config, "SECTIONS", ["automation"]):
|
||||||
await async_setup_component(hass, "config", {})
|
await async_setup_component(hass, "config", {})
|
||||||
@ -30,7 +43,8 @@ async def test_get_device_config(hass, hass_client):
|
|||||||
assert result == {"id": "moon"}
|
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."""
|
"""Test updating device config."""
|
||||||
with patch.object(config, "SECTIONS", ["automation"]):
|
with patch.object(config, "SECTIONS", ["automation"]):
|
||||||
await async_setup_component(hass, "config", {})
|
await async_setup_component(hass, "config", {})
|
||||||
@ -66,7 +80,8 @@ async def test_update_device_config(hass, hass_client):
|
|||||||
assert written[0] == orig_data
|
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."""
|
"""Test that we handle automations without ID."""
|
||||||
with patch.object(config, "SECTIONS", ["automation"]):
|
with patch.object(config, "SECTIONS", ["automation"]):
|
||||||
await async_setup_component(hass, "config", {})
|
await async_setup_component(hass, "config", {})
|
||||||
@ -110,15 +125,10 @@ async def test_bad_formatted_automations(hass, hass_client):
|
|||||||
assert orig_data[1] == {"id": "moon", "trigger": [], "condition": [], "action": []}
|
assert orig_data[1] == {"id": "moon", "trigger": [], "condition": [], "action": []}
|
||||||
|
|
||||||
|
|
||||||
async def test_delete_automation(hass, hass_client):
|
@pytest.mark.parametrize(
|
||||||
"""Test deleting an automation."""
|
"automation_config",
|
||||||
ent_reg = er.async_get(hass)
|
(
|
||||||
|
[
|
||||||
assert await async_setup_component(
|
|
||||||
hass,
|
|
||||||
"automation",
|
|
||||||
{
|
|
||||||
"automation": [
|
|
||||||
{
|
{
|
||||||
"id": "sun",
|
"id": "sun",
|
||||||
"trigger": {"platform": "event", "event_type": "test_event"},
|
"trigger": {"platform": "event", "event_type": "test_event"},
|
||||||
@ -129,9 +139,12 @@ async def test_delete_automation(hass, hass_client):
|
|||||||
"trigger": {"platform": "event", "event_type": "test_event"},
|
"trigger": {"platform": "event", "event_type": "test_event"},
|
||||||
"action": {"service": "test.automation"},
|
"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 len(ent_reg.entities) == 2
|
assert len(ent_reg.entities) == 2
|
||||||
|
|
||||||
|
@ -3,11 +3,19 @@ from http import HTTPStatus
|
|||||||
import json
|
import json
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
from homeassistant.components import config
|
from homeassistant.components import config
|
||||||
from homeassistant.config import DATA_CUSTOMIZE
|
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):
|
async def test_get_entity(hass, hass_client):
|
||||||
"""Test getting entity."""
|
"""Test getting entity."""
|
||||||
with patch.object(config, "SECTIONS", ["customize"]):
|
with patch.object(config, "SECTIONS", ["customize"]):
|
||||||
|
@ -3,13 +3,22 @@ from http import HTTPStatus
|
|||||||
import json
|
import json
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
from homeassistant.components import config
|
from homeassistant.components import config
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.util.yaml import dump
|
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."""
|
"""Test creating a scene."""
|
||||||
with patch.object(config, "SECTIONS", ["scene"]):
|
with patch.object(config, "SECTIONS", ["scene"]):
|
||||||
await async_setup_component(hass, "config", {})
|
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."""
|
"""Test updating a scene."""
|
||||||
with patch.object(config, "SECTIONS", ["scene"]):
|
with patch.object(config, "SECTIONS", ["scene"]):
|
||||||
await async_setup_component(hass, "config", {})
|
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."""
|
"""Test that we handle scene without ID."""
|
||||||
with patch.object(config, "SECTIONS", ["scene"]):
|
with patch.object(config, "SECTIONS", ["scene"]):
|
||||||
await async_setup_component(hass, "config", {})
|
await async_setup_component(hass, "config", {})
|
||||||
@ -163,20 +174,18 @@ async def test_bad_formatted_scene(hass, hass_client):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_delete_scene(hass, hass_client):
|
@pytest.mark.parametrize(
|
||||||
"""Test deleting a scene."""
|
"scene_config",
|
||||||
ent_reg = er.async_get(hass)
|
(
|
||||||
|
[
|
||||||
assert await async_setup_component(
|
|
||||||
hass,
|
|
||||||
"scene",
|
|
||||||
{
|
|
||||||
"scene": [
|
|
||||||
{"id": "light_on", "name": "Light on", "entities": {}},
|
{"id": "light_on", "name": "Light on", "entities": {}},
|
||||||
{"id": "light_off", "name": "Light off", "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 len(ent_reg.entities) == 2
|
assert len(ent_reg.entities) == 2
|
||||||
|
|
||||||
|
@ -2,9 +2,19 @@
|
|||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
from homeassistant.components import config
|
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):
|
async def test_delete_script(hass, hass_client):
|
||||||
"""Test deleting a script."""
|
"""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_speed.value == 50
|
||||||
assert acc.char_active.value == 0
|
assert acc.char_active.value == 0
|
||||||
|
|
||||||
|
call_turn_on = async_mock_service(hass, DOMAIN, "turn_on")
|
||||||
|
|
||||||
hk_driver.set_characteristics(
|
hk_driver.set_characteristics(
|
||||||
{
|
{
|
||||||
HAP_REPR_CHARS: [
|
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_speed.value == 50
|
||||||
assert acc.char_active.value == 1
|
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):
|
async def test_fan_set_all_one_shot(hass, hk_driver, events):
|
||||||
"""Test fan with speed."""
|
"""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.components.websocket_api.http import URL
|
||||||
from homeassistant.const import ATTR_NOW, EVENT_TIME_CHANGED
|
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.helpers import config_entry_oauth2_flow, event
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import location
|
from homeassistant.util import location
|
||||||
@ -232,8 +231,6 @@ def hass(loop, load_registries, hass_storage, request):
|
|||||||
request.function.__name__,
|
request.function.__name__,
|
||||||
) in IGNORE_UNCAUGHT_EXCEPTIONS:
|
) in IGNORE_UNCAUGHT_EXCEPTIONS:
|
||||||
continue
|
continue
|
||||||
if isinstance(ex, ServiceNotFound):
|
|
||||||
continue
|
|
||||||
raise ex
|
raise ex
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user