From 52c3b8370480926c58148acf2bed6c7049b18da0 Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 12 Sep 2015 15:28:40 +0200 Subject: [PATCH] Add start/stop test --- tests/mqtt/protocol/test_handler.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/mqtt/protocol/test_handler.py b/tests/mqtt/protocol/test_handler.py index 8b81766..e81cbe8 100644 --- a/tests/mqtt/protocol/test_handler.py +++ b/tests/mqtt/protocol/test_handler.py @@ -6,6 +6,7 @@ import asyncio from hbmqtt.plugins.manager import PluginManager from hbmqtt.session import Session from hbmqtt.mqtt.protocol.handler import ProtocolHandler +from hbmqtt.adapters import BufferReader, BufferWriter class ProtocolHandlerTest(unittest.TestCase): @@ -22,3 +23,20 @@ class ProtocolHandlerTest(unittest.TestCase): self.assertFalse(handler._pubrec_waiters) self.assertFalse(handler._pubrel_waiters) self.assertFalse(handler._pubcomp_waiters) + + def test_start_stop(self): + @asyncio.coroutine + def server_coro(reader, writer): + pass + + @asyncio.coroutine + def test_coro(): + s = Session() + buffer = b'' + s.reader = BufferReader(buffer) + s.writer = BufferWriter(buffer) + handler = ProtocolHandler(s, self.plugin_manager, loop=self.loop) + yield from handler.start() + yield from handler.stop() + return handler + handler = self.loop.run_until_complete(test_coro()) \ No newline at end of file