From 712da4c46e4ef5ee7995c37d8502c12391e23050 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Tue, 5 Jul 2011 21:29:31 -0700 Subject: Add test to check that presence events are firing. --- tests/test_stream_presence.py | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/test_stream_presence.py b/tests/test_stream_presence.py index 1d5caa98..0b086266 100644 --- a/tests/test_stream_presence.py +++ b/tests/test_stream_presence.py @@ -184,5 +184,56 @@ class TestStreamPresence(SleekTest): self.assertEqual(events, expected, "Incorrect events triggered: %s" % events) + def test_presence_events(self): + """Test that presence events are raised.""" + + events = [] + + self.stream_start() + + ptypes = ['available', 'away', 'dnd', 'xa', 'chat', + 'unavailable', 'subscribe', 'subscribed', + 'unsubscribe', 'unsubscribed'] + + for ptype in ptypes: + handler = lambda p: events.append(p['type']) + self.xmpp.add_event_handler('presence_%s' % ptype, handler) + + self.recv(""" + + """) + self.recv(""" + away + """) + self.recv(""" + dnd + """) + self.recv(""" + xa + """) + self.recv(""" + chat + """) + self.recv(""" + + """) + self.recv(""" + + """) + self.recv(""" + + """) + self.recv(""" + + """) + self.recv(""" + + """) + + time.sleep(.5) + + self.assertEqual(events, ptypes, + "Not all events raised: %s" % events) + suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPresence) -- cgit v1.2.3