mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Fix for MQTT config validation on the protocol field. (#1765)
This commit is contained in:
parent
b3bad10dab
commit
3aa4727b18
@ -90,7 +90,7 @@ CONFIG_SCHEMA = vol.Schema({
|
||||
vol.Optional(CONF_PASSWORD): cv.string,
|
||||
vol.Optional(CONF_CERTIFICATE): cv.isfile,
|
||||
vol.Optional(CONF_PROTOCOL, default=DEFAULT_PROTOCOL):
|
||||
[PROTOCOL_31, PROTOCOL_311],
|
||||
vol.All(cv.string, vol.In([PROTOCOL_31, PROTOCOL_311])),
|
||||
vol.Optional(CONF_EMBEDDED): _HBMQTT_CONFIG_SCHEMA,
|
||||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
@ -58,6 +58,17 @@ class TestMQTT(unittest.TestCase):
|
||||
}
|
||||
})
|
||||
|
||||
def test_setup_protocol_validation(self):
|
||||
"""Test for setup failure if connection to broker is missing."""
|
||||
with mock.patch('paho.mqtt.client.Client'):
|
||||
self.hass.config.components = []
|
||||
assert _setup_component(self.hass, mqtt.DOMAIN, {
|
||||
mqtt.DOMAIN: {
|
||||
mqtt.CONF_BROKER: 'test-broker',
|
||||
mqtt.CONF_PROTOCOL: 3.1,
|
||||
}
|
||||
})
|
||||
|
||||
def test_publish_calls_service(self):
|
||||
"""Test the publishing of call to services."""
|
||||
self.hass.bus.listen_once(EVENT_CALL_SERVICE, self.record_calls)
|
||||
|
Loading…
x
Reference in New Issue
Block a user