Move smtp constants to const.py (#99542)

This commit is contained in:
Rami Mosleh 2023-09-11 10:36:55 +03:00 committed by GitHub
parent 43fe8d16c3
commit eb0099dee8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 23 deletions

View file

@ -1,6 +1 @@
"""The smtp component."""
from homeassistant.const import Platform
DOMAIN = "smtp"
PLATFORMS = [Platform.NOTIFY]

View file

@ -0,0 +1,22 @@
"""Constants for the smtp integration."""
from typing import Final
DOMAIN: Final = "smtp"
ATTR_IMAGES: Final = "images" # optional embedded image file attachments
ATTR_HTML: Final = "html"
ATTR_SENDER_NAME: Final = "sender_name"
CONF_ENCRYPTION: Final = "encryption"
CONF_DEBUG: Final = "debug"
CONF_SERVER: Final = "server"
CONF_SENDER_NAME: Final = "sender_name"
DEFAULT_HOST: Final = "localhost"
DEFAULT_PORT: Final = 587
DEFAULT_TIMEOUT: Final = 5
DEFAULT_DEBUG: Final = False
DEFAULT_ENCRYPTION: Final = "starttls"
ENCRYPTION_OPTIONS: Final = ["tls", "starttls", "none"]

View file

@ -28,6 +28,7 @@ from homeassistant.const import (
CONF_TIMEOUT,
CONF_USERNAME,
CONF_VERIFY_SSL,
Platform,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
@ -36,26 +37,26 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
import homeassistant.util.dt as dt_util
from homeassistant.util.ssl import client_context
from . import DOMAIN, PLATFORMS
from .const import (
ATTR_HTML,
ATTR_IMAGES,
CONF_DEBUG,
CONF_ENCRYPTION,
CONF_SENDER_NAME,
CONF_SERVER,
DEFAULT_DEBUG,
DEFAULT_ENCRYPTION,
DEFAULT_HOST,
DEFAULT_PORT,
DEFAULT_TIMEOUT,
DOMAIN,
ENCRYPTION_OPTIONS,
)
PLATFORMS = [Platform.NOTIFY]
_LOGGER = logging.getLogger(__name__)
ATTR_IMAGES = "images" # optional embedded image file attachments
ATTR_HTML = "html"
CONF_ENCRYPTION = "encryption"
CONF_DEBUG = "debug"
CONF_SERVER = "server"
CONF_SENDER_NAME = "sender_name"
DEFAULT_HOST = "localhost"
DEFAULT_PORT = 587
DEFAULT_TIMEOUT = 5
DEFAULT_DEBUG = False
DEFAULT_ENCRYPTION = "starttls"
ENCRYPTION_OPTIONS = ["tls", "starttls", "none"]
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
{
vol.Required(CONF_RECIPIENT): vol.All(cv.ensure_list, [vol.Email()]),

View file

@ -6,7 +6,7 @@ import pytest
from homeassistant import config as hass_config
import homeassistant.components.notify as notify
from homeassistant.components.smtp import DOMAIN
from homeassistant.components.smtp.const import DOMAIN
from homeassistant.components.smtp.notify import MailNotificationService
from homeassistant.const import SERVICE_RELOAD
from homeassistant.core import HomeAssistant