From c4c0cf71eb9ed38af3b9e55b48c9763ba21635ac Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 13 May 2016 00:43:59 -0700 Subject: [PATCH] add test --- src/wormhole/test/test_server.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/wormhole/test/test_server.py b/src/wormhole/test/test_server.py index ad3e227..a32c878 100644 --- a/src/wormhole/test/test_server.py +++ b/src/wormhole/test/test_server.py @@ -201,6 +201,34 @@ class WebSocketAPI(ServerBase, unittest.TestCase): self.check_welcome(msg) self.assertEqual(self._rendezvous._apps, {}) + @inlineCallbacks + def test_claim(self): + r = self._rendezvous.get_app(u"appid") + c1 = yield self.make_client() + msg = yield c1.next_non_ack() + self.check_welcome(msg) + c1.send(u"bind", appid=u"appid", side=u"side") + c1.send(u"claim", channelid=u"1") + yield c1.sync() + self.assertEqual(r.get_claimed(), set(u"1")) + + c1.send(u"claim", channelid=u"2") + yield c1.sync() + self.assertEqual(r.get_claimed(), set([u"1", u"2"])) + + c1.send(u"claim", channelid=u"72aoqnnnbj7r2") + yield c1.sync() + self.assertEqual(r.get_claimed(), set([u"1", u"2", u"72aoqnnnbj7r2"])) + + c1.send(u"release", channelid=u"2") + yield c1.sync() + self.assertEqual(r.get_claimed(), set([u"1", u"72aoqnnnbj7r2"])) + + c1.send(u"release", channelid=u"1") + yield c1.sync() + self.assertEqual(r.get_claimed(), set([u"72aoqnnnbj7r2"])) + + @inlineCallbacks def test_allocate_1(self): c1 = yield self.make_client()