EventBus: return function to unlisten
This commit is contained in:
1 parent
62ba0fa7a2
commit
d9ecc4af64
11 files changed
+183
-83
No files matched your search
@@ -149,7 +149,7 @@ class TestMQTT(unittest.TestCase):
|
||||
|
||||
def test_subscribe_topic(self):
|
||||
"""Test the subscription of a topic."""
|
||||
mqtt.subscribe(self.hass, 'test-topic', self.record_calls)
|
||||
unsub = mqtt.subscribe(self.hass, 'test-topic', self.record_calls)
|
||||
|
||||
fire_mqtt_message(self.hass, 'test-topic', 'test-payload')
|
||||
|
||||
@@ -158,6 +158,13 @@ class TestMQTT(unittest.TestCase):
|
||||
self.assertEqual('test-topic', self.calls[0][0])
|
||||
self.assertEqual('test-payload', self.calls[0][1])
|
||||
|
||||
unsub()
|
||||
|
||||
fire_mqtt_message(self.hass, 'test-topic', 'test-payload')
|
||||
|
||||
self.hass.pool.block_till_done()
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_subscribe_topic_not_match(self):
|
||||
"""Test if subscribed topic is not a match."""
|
||||
mqtt.subscribe(self.hass, 'test-topic', self.record_calls)
|
||||
|
||||
Reference in new issue
Block a user