Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -7,17 +7,12 @@ from datetime import timedelta
|
||||
from homeassistant import setup
|
||||
import homeassistant.components.ring as ring
|
||||
|
||||
from tests.common import (
|
||||
get_test_config_dir, get_test_home_assistant, load_fixture)
|
||||
from tests.common import get_test_config_dir, get_test_home_assistant, load_fixture
|
||||
|
||||
ATTRIBUTION = 'Data provided by Ring.com'
|
||||
ATTRIBUTION = "Data provided by Ring.com"
|
||||
|
||||
VALID_CONFIG = {
|
||||
"ring": {
|
||||
"username": "foo",
|
||||
"password": "bar",
|
||||
"scan_interval": timedelta(10)
|
||||
}
|
||||
"ring": {"username": "foo", "password": "bar", "scan_interval": timedelta(10)}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,33 +38,46 @@ class TestRing(unittest.TestCase):
|
||||
@requests_mock.Mocker()
|
||||
def test_setup(self, mock):
|
||||
"""Test the setup."""
|
||||
mock.post('https://oauth.ring.com/oauth/token',
|
||||
text=load_fixture('ring_oauth.json'))
|
||||
mock.post('https://api.ring.com/clients_api/session',
|
||||
text=load_fixture('ring_session.json'))
|
||||
mock.get('https://api.ring.com/clients_api/ring_devices',
|
||||
text=load_fixture('ring_devices.json'))
|
||||
mock.get('https://api.ring.com/clients_api/chimes/999999/health',
|
||||
text=load_fixture('ring_chime_health_attrs.json'))
|
||||
mock.get('https://api.ring.com/clients_api/doorbots/987652/health',
|
||||
text=load_fixture('ring_doorboot_health_attrs.json'))
|
||||
mock.post(
|
||||
"https://oauth.ring.com/oauth/token", text=load_fixture("ring_oauth.json")
|
||||
)
|
||||
mock.post(
|
||||
"https://api.ring.com/clients_api/session",
|
||||
text=load_fixture("ring_session.json"),
|
||||
)
|
||||
mock.get(
|
||||
"https://api.ring.com/clients_api/ring_devices",
|
||||
text=load_fixture("ring_devices.json"),
|
||||
)
|
||||
mock.get(
|
||||
"https://api.ring.com/clients_api/chimes/999999/health",
|
||||
text=load_fixture("ring_chime_health_attrs.json"),
|
||||
)
|
||||
mock.get(
|
||||
"https://api.ring.com/clients_api/doorbots/987652/health",
|
||||
text=load_fixture("ring_doorboot_health_attrs.json"),
|
||||
)
|
||||
response = ring.setup(self.hass, self.config)
|
||||
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'))
|
||||
mock.post(
|
||||
"https://api.ring.com/clients_api/session",
|
||||
text=load_fixture("ring_session.json"),
|
||||
)
|
||||
conf = deepcopy(VALID_CONFIG)
|
||||
del conf['ring']['username']
|
||||
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'))
|
||||
mock.post(
|
||||
"https://api.ring.com/clients_api/session",
|
||||
text=load_fixture("ring_session.json"),
|
||||
)
|
||||
conf = deepcopy(VALID_CONFIG)
|
||||
del conf['ring']['password']
|
||||
del conf["ring"]["password"]
|
||||
assert not setup.setup_component(self.hass, ring.DOMAIN, conf)
|
||||
Reference in new issue
Block a user