mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-04-02 08:12:47 +01:00
Support for deconz discovery & cleanup (#974)
* Support for deconz discovery & cleanup * Split discovery * Fix lint * Fix lint / import
This commit is contained in:
1
tests/discovery/__init__.py
Normal file
1
tests/discovery/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Tests for discovery."""
|
||||
19
tests/discovery/test_deconz.py
Normal file
19
tests/discovery/test_deconz.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""Test DeConz discovery."""
|
||||
|
||||
import voluptuous as vol
|
||||
import pytest
|
||||
|
||||
from hassio.discovery.validate import valid_discovery_config
|
||||
|
||||
|
||||
def test_good_config():
|
||||
"""Test good deconz config."""
|
||||
|
||||
valid_discovery_config("deconz", {"host": "test", "port": 3812})
|
||||
|
||||
|
||||
def test_bad_config():
|
||||
"""Test good deconz config."""
|
||||
|
||||
with pytest.raises(vol.Invalid):
|
||||
valid_discovery_config("deconz", {"host": "test"})
|
||||
21
tests/discovery/test_mqtt.py
Normal file
21
tests/discovery/test_mqtt.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""Test MQTT discovery."""
|
||||
|
||||
import voluptuous as vol
|
||||
import pytest
|
||||
|
||||
from hassio.discovery.validate import valid_discovery_config
|
||||
|
||||
|
||||
def test_good_config():
|
||||
"""Test good mqtt config."""
|
||||
|
||||
valid_discovery_config(
|
||||
"mqtt", {"host": "test", "port": 3812, "username": "bla", "ssl": True}
|
||||
)
|
||||
|
||||
|
||||
def test_bad_config():
|
||||
"""Test good mqtt config."""
|
||||
|
||||
with pytest.raises(vol.Invalid):
|
||||
valid_discovery_config("mqtt", {"host": "test", "username": "bla", "ssl": True})
|
||||
21
tests/discovery/test_validate.py
Normal file
21
tests/discovery/test_validate.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""Test validate of discovery."""
|
||||
|
||||
import voluptuous as vol
|
||||
import pytest
|
||||
|
||||
from hassio.discovery import validate
|
||||
|
||||
|
||||
def test_valid_services():
|
||||
"""Validate that service is valid."""
|
||||
|
||||
for service in ("mqtt", "deconz"):
|
||||
validate.valid_discovery_service(service)
|
||||
|
||||
|
||||
def test_invalid_services():
|
||||
"""Test that validate is invalid for a service."""
|
||||
|
||||
for service in ("fadsfasd", "203432"):
|
||||
with pytest.raises(vol.Invalid):
|
||||
validate.valid_discovery_service(service)
|
||||
Reference in New Issue
Block a user