mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Add ring switch platform (#25612)
* Add in a switch platform to ring. * Changes following code review * remove tests for now * remove the request to call update * support the new type of test * update after running black * fix comment * fixes following code review * Remove ring cache file * patch out io code * Move the patches to within a fixture * missing period
This commit is contained in:
committed by
Martin Hjelmare
parent
7ff7c7b9f5
commit
9e8df936ac
54
tests/components/ring/conftest.py
Normal file
54
tests/components/ring/conftest.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""Configuration for Ring tests."""
|
||||
import requests_mock
|
||||
import pytest
|
||||
from tests.common import load_fixture
|
||||
from asynctest import patch
|
||||
|
||||
|
||||
@pytest.fixture(name="ring_mock")
|
||||
def ring_save_mock():
|
||||
"""Fixture to mock a ring."""
|
||||
with patch("ring_doorbell._exists_cache", return_value=False):
|
||||
with patch("ring_doorbell._save_cache", return_value=True) as save_mock:
|
||||
yield save_mock
|
||||
|
||||
|
||||
@pytest.fixture(name="requests_mock")
|
||||
def requests_mock_fixture(ring_mock):
|
||||
"""Fixture to provide a requests mocker."""
|
||||
with requests_mock.mock() as mock:
|
||||
# Note all devices have an id of 987652, but a different device_id.
|
||||
# the device_id is used as our unique_id, but the id is what is sent
|
||||
# to the APIs, which is why every mock uses that id.
|
||||
|
||||
# Mocks the response for authenticating
|
||||
mock.post(
|
||||
"https://oauth.ring.com/oauth/token", text=load_fixture("ring_oauth.json")
|
||||
)
|
||||
# Mocks the response for getting the login session
|
||||
mock.post(
|
||||
"https://api.ring.com/clients_api/session",
|
||||
text=load_fixture("ring_session.json"),
|
||||
)
|
||||
# Mocks the response for getting all the devices
|
||||
mock.get(
|
||||
"https://api.ring.com/clients_api/ring_devices",
|
||||
text=load_fixture("ring_devices.json"),
|
||||
)
|
||||
# Mocks the response for getting the history of a device
|
||||
mock.get(
|
||||
"https://api.ring.com/clients_api/doorbots/987652/history",
|
||||
text=load_fixture("ring_doorbots.json"),
|
||||
)
|
||||
# Mocks the response for getting the health of a device
|
||||
mock.get(
|
||||
"https://api.ring.com/clients_api/doorbots/987652/health",
|
||||
text=load_fixture("ring_doorboot_health_attrs.json"),
|
||||
)
|
||||
# Mocks the response for getting a chimes health
|
||||
mock.get(
|
||||
"https://api.ring.com/clients_api/chimes/999999/health",
|
||||
text=load_fixture("ring_chime_health_attrs.json"),
|
||||
)
|
||||
|
||||
yield mock
|
||||
Reference in New Issue
Block a user