init home-assistant

This commit is contained in:
2026-11-19 15:15:32 -05:00
parent 2e81d9d300
commit feec6ef9fb
19230 changed files with 3335526 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
"""Notify tests for the Google Mail integration."""
from unittest.mock import patch
import pytest
from voluptuous.error import Invalid
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
from homeassistant.core import HomeAssistant
from .conftest import BUILD, ComponentSetup
async def test_notify(
hass: HomeAssistant,
setup_integration: ComponentSetup,
) -> None:
"""Test service call draft email."""
await setup_integration()
with patch(BUILD) as mock_client:
await hass.services.async_call(
NOTIFY_DOMAIN,
"example_gmail_com",
{
"title": "Test",
"message": "test email",
"target": "text@example.com",
},
blocking=True,
)
assert len(mock_client.mock_calls) == 5
with patch(BUILD) as mock_client:
await hass.services.async_call(
NOTIFY_DOMAIN,
"example_gmail_com",
{
"title": "Test",
"message": "test email",
"target": "text@example.com",
"data": {"send": False},
},
blocking=True,
)
assert len(mock_client.mock_calls) == 5
async def test_notify_voluptuous_error(
hass: HomeAssistant,
setup_integration: ComponentSetup,
) -> None:
"""Test voluptuous error thrown when drafting email."""
await setup_integration()
with pytest.raises(ValueError) as ex:
await hass.services.async_call(
NOTIFY_DOMAIN,
"example_gmail_com",
{
"title": "Test",
"message": "test email",
},
blocking=True,
)
assert ex.match("recipient address required")
with pytest.raises(Invalid) as ex:
await hass.services.async_call(
NOTIFY_DOMAIN,
"example_gmail_com",
{
"title": "Test",
},
blocking=True,
)
assert ex.getrepr("required key not provided")