summaryrefslogtreecommitdiff
path: root/tests/test_stream_presence.py
diff options
context:
space:
mode:
authorNathan Fritz <nathan@andyet.net>2011-08-10 13:37:49 -0700
committerNathan Fritz <nathan@andyet.net>2011-08-10 13:37:49 -0700
commita189cb8333d5f59caa9015f0ded222696987d957 (patch)
tree467f202bc7f85a4cde85a5add3c372515f18adc3 /tests/test_stream_presence.py
parent0d4825d3ea0562f305939e653e3d414e70e4aaa8 (diff)
parent156b3200e3b5ad1b2e64eecc48cdc792f7b2ffd9 (diff)
downloadslixmpp-a189cb8333d5f59caa9015f0ded222696987d957.tar.gz
slixmpp-a189cb8333d5f59caa9015f0ded222696987d957.tar.bz2
slixmpp-a189cb8333d5f59caa9015f0ded222696987d957.tar.xz
slixmpp-a189cb8333d5f59caa9015f0ded222696987d957.zip
Merge branch 'develop' of github.com:fritzy/SleekXMPP into develop
Diffstat (limited to 'tests/test_stream_presence.py')
-rw-r--r--tests/test_stream_presence.py51
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)