diff options
author | Lance Stout <lancestout@gmail.com> | 2011-07-27 19:36:04 -0700 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-07-27 19:36:04 -0700 |
commit | d7fe724145c2e01d1028dab773fb49414c6856dd (patch) | |
tree | 460331e5949b92637c79275aed001c85125f7afe /tests/test_stream_presence.py | |
parent | 20df6348a4c8262a40578d84c934f9a15431d925 (diff) | |
parent | e022b2a36c342b6a83d7c7f0a39dfb851cdfd2de (diff) | |
download | slixmpp-d7fe724145c2e01d1028dab773fb49414c6856dd.tar.gz slixmpp-d7fe724145c2e01d1028dab773fb49414c6856dd.tar.bz2 slixmpp-d7fe724145c2e01d1028dab773fb49414c6856dd.tar.xz slixmpp-d7fe724145c2e01d1028dab773fb49414c6856dd.zip |
Merge branch 'develop' into exceptions
Diffstat (limited to 'tests/test_stream_presence.py')
-rw-r--r-- | tests/test_stream_presence.py | 51 |
1 files changed, 51 insertions, 0 deletions
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(""" + <presence /> + """) + self.recv(""" + <presence><show>away</show></presence> + """) + self.recv(""" + <presence><show>dnd</show></presence> + """) + self.recv(""" + <presence><show>xa</show></presence> + """) + self.recv(""" + <presence><show>chat</show></presence> + """) + self.recv(""" + <presence type="unavailable" /> + """) + self.recv(""" + <presence type="subscribe" /> + """) + self.recv(""" + <presence type="subscribed" /> + """) + self.recv(""" + <presence type="unsubscribe" /> + """) + self.recv(""" + <presence type="unsubscribed" /> + """) + + time.sleep(.5) + + self.assertEqual(events, ptypes, + "Not all events raised: %s" % events) + suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPresence) |