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