diff options
Diffstat (limited to 'rrd/tests/test_mqtt.py')
-rw-r--r-- | rrd/tests/test_mqtt.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/rrd/tests/test_mqtt.py b/rrd/tests/test_mqtt.py new file mode 100644 index 0000000..4ea0852 --- /dev/null +++ b/rrd/tests/test_mqtt.py @@ -0,0 +1,30 @@ +import time + +import django.test + +from .. import mqtt + +class TestMQTT(django.test.TestCase): + def setUp(self): + self.mqtt = mqtt.MQTTClient() + self.mqtt.loop_start() + time.sleep(0.1) + if not self.mqtt.connected: + self.skipTest("Could not find an mqtt server") + + def tearDown(self): + self.mqtt.loop_stop() + + def test_disconnect(self): + # after disconnecting from the mqtt server, we should + # automatically reconnect + self.mqtt.disconnect() + time.sleep(2) + self.assertTrue(self.mqtt.connected) + + def test_disconnect_and_stay(self): + # unless we really want to force a disconnection + self.mqtt.disconnect(reconnect=False) + time.sleep(2) + self.assertFalse(self.mqtt.connected) + self.assertFalse(self.mqtt.reconnect) |