2017-03-31 11:53:56 -04:00
|
|
|
"""The tests for the Ring component."""
|
2019-12-09 11:58:40 +01:00
|
|
|
from datetime import timedelta
|
|
|
|
|
2017-03-31 11:53:56 -04:00
|
|
|
import homeassistant.components.ring as ring
|
2020-10-04 13:05:49 +01:00
|
|
|
from homeassistant.setup import async_setup_component
|
2017-03-31 11:53:56 -04:00
|
|
|
|
2020-10-04 13:05:49 +01:00
|
|
|
from tests.common import load_fixture
|
2017-03-31 11:53:56 -04:00
|
|
|
|
2019-07-31 12:25:30 -07:00
|
|
|
ATTRIBUTION = "Data provided by Ring.com"
|
2017-03-31 11:53:56 -04:00
|
|
|
|
|
|
|
VALID_CONFIG = {
|
2019-07-31 12:25:30 -07:00
|
|
|
"ring": {"username": "foo", "password": "bar", "scan_interval": timedelta(10)}
|
2017-03-31 11:53:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-04 13:05:49 +01:00
|
|
|
async def test_setup(hass, requests_mock):
|
|
|
|
"""Test the setup."""
|
|
|
|
await async_setup_component(hass, ring.DOMAIN, {})
|
|
|
|
|
|
|
|
requests_mock.post(
|
2021-11-01 20:47:05 -07:00
|
|
|
"https://oauth.ring.com/oauth/token", text=load_fixture("oauth.json", "ring")
|
2020-10-04 13:05:49 +01:00
|
|
|
)
|
|
|
|
requests_mock.post(
|
|
|
|
"https://api.ring.com/clients_api/session",
|
2021-11-01 20:47:05 -07:00
|
|
|
text=load_fixture("session.json", "ring"),
|
2020-10-04 13:05:49 +01:00
|
|
|
)
|
|
|
|
requests_mock.get(
|
|
|
|
"https://api.ring.com/clients_api/ring_devices",
|
2021-11-01 20:47:05 -07:00
|
|
|
text=load_fixture("devices.json", "ring"),
|
2020-10-04 13:05:49 +01:00
|
|
|
)
|
|
|
|
requests_mock.get(
|
|
|
|
"https://api.ring.com/clients_api/chimes/999999/health",
|
2021-11-01 20:47:05 -07:00
|
|
|
text=load_fixture("chime_health_attrs.json", "ring"),
|
2020-10-04 13:05:49 +01:00
|
|
|
)
|
|
|
|
requests_mock.get(
|
|
|
|
"https://api.ring.com/clients_api/doorbots/987652/health",
|
2021-11-01 20:47:05 -07:00
|
|
|
text=load_fixture("doorboot_health_attrs.json", "ring"),
|
2020-10-04 13:05:49 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
assert await ring.async_setup(hass, VALID_CONFIG)
|