summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-07-27 19:35:42 -0700
committerLance Stout <lancestout@gmail.com>2011-07-27 19:35:42 -0700
commitad978700fc891602c826dea03615c396f39364a0 (patch)
tree76315f3d39cd7209c71a164864f5e815d1a27d07 /tests
parent48fb7006f75dd03caa23f61cb512f9002fe91b90 (diff)
parente022b2a36c342b6a83d7c7f0a39dfb851cdfd2de (diff)
downloadslixmpp-ad978700fc891602c826dea03615c396f39364a0.tar.gz
slixmpp-ad978700fc891602c826dea03615c396f39364a0.tar.bz2
slixmpp-ad978700fc891602c826dea03615c396f39364a0.tar.xz
slixmpp-ad978700fc891602c826dea03615c396f39364a0.zip
Merge branch 'develop' into roster
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream_presence.py51
-rw-r--r--tests/test_stream_xep_0066.py28
2 files changed, 51 insertions, 28 deletions
diff --git a/tests/test_stream_presence.py b/tests/test_stream_presence.py
index 3e0933d7..21535dce 100644
--- a/tests/test_stream_presence.py
+++ b/tests/test_stream_presence.py
@@ -200,5 +200,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)
diff --git a/tests/test_stream_xep_0066.py b/tests/test_stream_xep_0066.py
index 3dbaf840..e3f2ddfa 100644
--- a/tests/test_stream_xep_0066.py
+++ b/tests/test_stream_xep_0066.py
@@ -40,33 +40,5 @@ class TestOOB(SleekTest):
t.join()
- def testReceiveOOB(self):
- """Test receiving an OOB request."""
- self.stream_start(plugins=['xep_0066', 'xep_0030'])
-
- events = []
-
- def receive_oob(iq):
- events.append(iq['oob_transfer']['url'])
-
- self.xmpp.add_event_handler('oob_transfer', receive_oob)
-
- self.recv("""
- <iq to="tester@localhost"
- from="user@example.com"
- type="set" id="1">
- <query xmlns="jabber:iq:oob">
- <url>http://github.com/fritzy/SleekXMPP/blob/master/README</url>
- <desc>SleekXMPP README</desc>
- </query>
- </iq>
- """)
-
- time.sleep(0.1)
-
- self.assertEqual(events,
- ['http://github.com/fritzy/SleekXMPP/blob/master/README'],
- 'URL was not received: %s' % events)
-
suite = unittest.TestLoader().loadTestsFromTestCase(TestOOB)