1
mirror of https://github.com/home-assistant/core synced 2024-09-03 08:14:07 +02:00

Remove YAML config from Ring integration (#32039)

This commit is contained in:
Paulus Schoutsen 2020-02-21 17:36:19 -08:00 committed by GitHub
parent dc15b9c28e
commit ced870c588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 57 deletions

View File

@ -9,12 +9,9 @@ from typing import Optional
from oauthlib.oauth2 import AccessDeniedError
import requests
from ring_doorbell import Auth, Ring
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME, __version__
from homeassistant.const import __version__
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.util.async_ import run_callback_threadsafe
@ -30,18 +27,6 @@ DEFAULT_ENTITY_NAMESPACE = "ring"
PLATFORMS = ("binary_sensor", "light", "sensor", "switch", "camera")
CONFIG_SCHEMA = vol.Schema(
{
vol.Optional(DOMAIN): vol.Schema(
{
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
}
)
},
extra=vol.ALLOW_EXTRA,
)
async def async_setup(hass, config):
"""Set up the Ring component."""
@ -56,16 +41,6 @@ async def async_setup(hass, config):
await hass.async_add_executor_job(legacy_cleanup)
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_IMPORT},
data={
"username": config[DOMAIN]["username"],
"password": config[DOMAIN]["password"],
},
)
)
return True

View File

@ -75,13 +75,6 @@ class RingConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
step_id="2fa", data_schema=vol.Schema({"2fa": str}),
)
async def async_step_import(self, user_input):
"""Handle import."""
if self._async_current_entries():
return self.async_abort(reason="already_configured")
return await self.async_step_user(user_input)
class Require2FA(exceptions.HomeAssistantError):
"""Error to indicate we require 2FA."""

View File

@ -1,12 +1,10 @@
"""The tests for the Ring component."""
from asyncio import run_coroutine_threadsafe
from copy import deepcopy
from datetime import timedelta
import unittest
import requests_mock
from homeassistant import setup
import homeassistant.components.ring as ring
from tests.common import get_test_home_assistant, load_fixture
@ -57,25 +55,3 @@ class TestRing(unittest.TestCase):
).result()
assert response
@requests_mock.Mocker()
def test_setup_component_no_login(self, mock):
"""Test the setup when no login is configured."""
mock.post(
"https://api.ring.com/clients_api/session",
text=load_fixture("ring_session.json"),
)
conf = deepcopy(VALID_CONFIG)
del conf["ring"]["username"]
assert not setup.setup_component(self.hass, ring.DOMAIN, conf)
@requests_mock.Mocker()
def test_setup_component_no_pwd(self, mock):
"""Test the setup when no password is configured."""
mock.post(
"https://api.ring.com/clients_api/session",
text=load_fixture("ring_session.json"),
)
conf = deepcopy(VALID_CONFIG)
del conf["ring"]["password"]
assert not setup.setup_component(self.hass, ring.DOMAIN, conf)