Remove async_setup from ring (#93902)

This commit is contained in:
Erik Montnemery 2023-06-01 11:34:18 +02:00 committed by GitHub
parent ba76bbee44
commit 08bfe8f5cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 30 deletions

View File

@ -6,7 +6,6 @@ from collections.abc import Callable
from datetime import timedelta from datetime import timedelta
from functools import partial from functools import partial
import logging import logging
from pathlib import Path
from typing import Any from typing import Any
from oauthlib.oauth2 import AccessDeniedError from oauthlib.oauth2 import AccessDeniedError
@ -18,7 +17,6 @@ from homeassistant.const import Platform, __version__
from homeassistant.core import HomeAssistant, ServiceCall, callback from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.async_ import run_callback_threadsafe from homeassistant.util.async_ import run_callback_threadsafe
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -41,22 +39,6 @@ PLATFORMS = [
] ]
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the Ring component."""
if DOMAIN not in config:
return True
def legacy_cleanup():
"""Clean up old tokens."""
old_cache = Path(hass.config.path(".ring_cache.pickle"))
if old_cache.is_file():
old_cache.unlink()
await hass.async_add_executor_job(legacy_cleanup)
return True
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry.""" """Set up a config entry."""

View File

@ -22,8 +22,6 @@ async def test_form(hass: HomeAssistant) -> None:
fetch_token=Mock(return_value={"access_token": "mock-token"}) fetch_token=Mock(return_value={"access_token": "mock-token"})
), ),
), patch( ), patch(
"homeassistant.components.ring.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.ring.async_setup_entry", "homeassistant.components.ring.async_setup_entry",
return_value=True, return_value=True,
) as mock_setup_entry: ) as mock_setup_entry:
@ -39,7 +37,6 @@ async def test_form(hass: HomeAssistant) -> None:
"username": "hello@home-assistant.io", "username": "hello@home-assistant.io",
"token": {"access_token": "mock-token"}, "token": {"access_token": "mock-token"},
} }
assert len(mock_setup.mock_calls) == 1
assert len(mock_setup_entry.mock_calls) == 1 assert len(mock_setup_entry.mock_calls) == 1

View File

@ -1,5 +1,4 @@
"""The tests for the Ring component.""" """The tests for the Ring component."""
from datetime import timedelta
import requests_mock import requests_mock
@ -9,12 +8,6 @@ from homeassistant.setup import async_setup_component
from tests.common import load_fixture from tests.common import load_fixture
ATTRIBUTION = "Data provided by Ring.com"
VALID_CONFIG = {
"ring": {"username": "foo", "password": "bar", "scan_interval": timedelta(10)}
}
async def test_setup(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> None: async def test_setup(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -> None:
"""Test the setup.""" """Test the setup."""
@ -39,5 +32,3 @@ async def test_setup(hass: HomeAssistant, requests_mock: requests_mock.Mocker) -
"https://api.ring.com/clients_api/doorbots/987652/health", "https://api.ring.com/clients_api/doorbots/987652/health",
text=load_fixture("doorboot_health_attrs.json", "ring"), text=load_fixture("doorboot_health_attrs.json", "ring"),
) )
assert await ring.async_setup(hass, VALID_CONFIG)