From 1f7199cf009205eb1779a87fb28e628ad4d5d41f Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 19 Dec 2022 14:05:15 +0100 Subject: [PATCH] Add OTBR discovery (#4040) * Add OTBR discovery * Fix typo * Move constants to correct file * Drop Web Service port * Use existing port constant --- supervisor/discovery/services/otbr.py | 13 +++++++++++++ tests/discovery/test_otbr.py | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 supervisor/discovery/services/otbr.py create mode 100644 tests/discovery/test_otbr.py diff --git a/supervisor/discovery/services/otbr.py b/supervisor/discovery/services/otbr.py new file mode 100644 index 000000000..24992e59c --- /dev/null +++ b/supervisor/discovery/services/otbr.py @@ -0,0 +1,13 @@ +"""Discovery service for OpenThread Border Router.""" +import voluptuous as vol + +from ...validate import network_port +from ..const import ATTR_HOST, ATTR_PORT + +# pylint: disable=no-value-for-parameter +SCHEMA = vol.Schema( + { + vol.Required(ATTR_HOST): str, + vol.Required(ATTR_PORT): network_port, + } +) diff --git a/tests/discovery/test_otbr.py b/tests/discovery/test_otbr.py new file mode 100644 index 000000000..52048cfb4 --- /dev/null +++ b/tests/discovery/test_otbr.py @@ -0,0 +1,22 @@ +"""Test OTBR discovery.""" + +import pytest +import voluptuous as vol + +from supervisor.discovery.validate import valid_discovery_config + + +def test_good_config(): + """Test good OTBR config.""" + + valid_discovery_config( + "otbr", + {"host": "test", "port": 3812}, + ) + + +def test_bad_config(): + """Test bad OTBR config.""" + + with pytest.raises(vol.Invalid): + valid_discovery_config("otbr", {"host": "test"})