summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-02-24 16:19:45 -0500
committerLance Stout <lancestout@gmail.com>2011-02-24 16:19:45 -0500
commit42c8f6ae877535c48424e5bcb8233f5d07dcfb7d (patch)
tree5d6892cfd29cb009b952bc06b398bd8cf03ac541 /tests
parente4f3b777f9d6c57a2d05296079828609e6b18375 (diff)
parent45ccb313560fbfbc0354ebac9116ecb9ff963a47 (diff)
downloadslixmpp-42c8f6ae877535c48424e5bcb8233f5d07dcfb7d.tar.gz
slixmpp-42c8f6ae877535c48424e5bcb8233f5d07dcfb7d.tar.bz2
slixmpp-42c8f6ae877535c48424e5bcb8233f5d07dcfb7d.tar.xz
slixmpp-42c8f6ae877535c48424e5bcb8233f5d07dcfb7d.zip
Merge branch 'develop' into roster
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stanza_xep_0085.py37
-rw-r--r--tests/test_stream_xep_0085.py59
2 files changed, 76 insertions, 20 deletions
diff --git a/tests/test_stanza_xep_0085.py b/tests/test_stanza_xep_0085.py
index 5db7139a..b08404e2 100644
--- a/tests/test_stanza_xep_0085.py
+++ b/tests/test_stanza_xep_0085.py
@@ -4,11 +4,7 @@ import sleekxmpp.plugins.xep_0085 as xep_0085
class TestChatStates(SleekTest):
def setUp(self):
- register_stanza_plugin(Message, xep_0085.Active)
- register_stanza_plugin(Message, xep_0085.Composing)
- register_stanza_plugin(Message, xep_0085.Gone)
- register_stanza_plugin(Message, xep_0085.Inactive)
- register_stanza_plugin(Message, xep_0085.Paused)
+ register_stanza_plugin(Message, xep_0085.ChatState)
def testCreateChatState(self):
"""Testing creating chat states."""
@@ -20,25 +16,26 @@ class TestChatStates(SleekTest):
"""
msg = self.Message()
- msg['chat_state'].active()
- self.check(msg, xmlstring % 'active',
- use_values=False)
- msg['chat_state'].composing()
- self.check(msg, xmlstring % 'composing',
- use_values=False)
+ self.assertEqual(msg['chat_state'], '')
+ self.check(msg, "<message />", use_values=False)
+ msg['chat_state'] = 'active'
+ self.check(msg, xmlstring % 'active', use_values=False)
- msg['chat_state'].gone()
- self.check(msg, xmlstring % 'gone',
- use_values=False)
+ msg['chat_state'] = 'composing'
+ self.check(msg, xmlstring % 'composing', use_values=False)
- msg['chat_state'].inactive()
- self.check(msg, xmlstring % 'inactive',
- use_values=False)
+ msg['chat_state'] = 'gone'
+ self.check(msg, xmlstring % 'gone', use_values=False)
- msg['chat_state'].paused()
- self.check(msg, xmlstring % 'paused',
- use_values=False)
+ msg['chat_state'] = 'inactive'
+ self.check(msg, xmlstring % 'inactive', use_values=False)
+
+ msg['chat_state'] = 'paused'
+ self.check(msg, xmlstring % 'paused', use_values=False)
+
+ del msg['chat_state']
+ self.check(msg, "<message />")
suite = unittest.TestLoader().loadTestsFromTestCase(TestChatStates)
diff --git a/tests/test_stream_xep_0085.py b/tests/test_stream_xep_0085.py
new file mode 100644
index 00000000..2a814805
--- /dev/null
+++ b/tests/test_stream_xep_0085.py
@@ -0,0 +1,59 @@
+import threading
+import time
+
+from sleekxmpp.test import *
+
+
+class TestStreamChatStates(SleekTest):
+
+ def tearDown(self):
+ self.stream_close()
+
+ def testChatStates(self):
+ self.stream_start(mode='client', plugins=['xep_0030', 'xep_0085'])
+
+ results = []
+
+ def handle_state(msg):
+ results.append(msg['chat_state'])
+
+ self.xmpp.add_event_handler('chatstate_active', handle_state)
+ self.xmpp.add_event_handler('chatstate_inactive', handle_state)
+ self.xmpp.add_event_handler('chatstate_paused', handle_state)
+ self.xmpp.add_event_handler('chatstate_gone', handle_state)
+ self.xmpp.add_event_handler('chatstate_composing', handle_state)
+
+ self.recv("""
+ <message>
+ <active xmlns="http://jabber.org/protocol/chatstates" />
+ </message>
+ """)
+ self.recv("""
+ <message>
+ <inactive xmlns="http://jabber.org/protocol/chatstates" />
+ </message>
+ """)
+ self.recv("""
+ <message>
+ <paused xmlns="http://jabber.org/protocol/chatstates" />
+ </message>
+ """)
+ self.recv("""
+ <message>
+ <composing xmlns="http://jabber.org/protocol/chatstates" />
+ </message>
+ """)
+ self.recv("""
+ <message>
+ <gone xmlns="http://jabber.org/protocol/chatstates" />
+ </message>
+ """)
+
+ # Give event queue time to process
+ time.sleep(0.3)
+ expected = ['active', 'inactive', 'paused', 'composing', 'gone']
+ self.failUnless(results == expected,
+ "Chat state event not handled: %s" % results)
+
+
+suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamChatStates)