diff --git a/tests/test_stream_presence.py b/tests/test_stream_presence.py
index 1d5caa9..0b08626 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)