1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Fix MQTT payload decode returning prematurely (#12420)

* Fix MQTT returning prematurely

* Add test
This commit is contained in:
Otto Winter
2018-02-15 07:00:49 +01:00
committed by Paulus Schoutsen
parent c25c4c85d6
commit 5d4b1ecd3b
2 changed files with 12 additions and 1 deletions

View File

@@ -172,6 +172,17 @@ class TestMQTTCallbacks(unittest.TestCase):
"b'\\x9a' on test-topic with encoding utf-8",
test_handle.output[0])
def test_all_subscriptions_run_when_decode_fails(self):
"""Test all other subscriptions still run when decode fails for one."""
mqtt.subscribe(self.hass, 'test-topic', self.record_calls,
encoding='ascii')
mqtt.subscribe(self.hass, 'test-topic', self.record_calls)
fire_mqtt_message(self.hass, 'test-topic', '°C')
self.hass.block_till_done()
self.assertEqual(1, len(self.calls))
def test_subscribe_topic(self):
"""Test the subscription of a topic."""
unsub = mqtt.subscribe(self.hass, 'test-topic', self.record_calls)