4 from slixmpp
.test
import SlixTest
7 class TestStreamChatStates(SlixTest
):
12 def testChatStates(self
):
13 self
.stream_start(mode
='client', plugins
=['xep_0030', 'xep_0085'])
17 def handle_state(msg
):
18 results
.append(msg
['chat_state'])
20 self
.xmpp
.add_event_handler('chatstate_active', handle_state
)
21 self
.xmpp
.add_event_handler('chatstate_inactive', handle_state
)
22 self
.xmpp
.add_event_handler('chatstate_paused', handle_state
)
23 self
.xmpp
.add_event_handler('chatstate_gone', handle_state
)
24 self
.xmpp
.add_event_handler('chatstate_composing', handle_state
)
28 <active xmlns="http://jabber.org/protocol/chatstates" />
33 <inactive xmlns="http://jabber.org/protocol/chatstates" />
38 <paused xmlns="http://jabber.org/protocol/chatstates" />
43 <composing xmlns="http://jabber.org/protocol/chatstates" />
48 <gone xmlns="http://jabber.org/protocol/chatstates" />
52 # Give event queue time to process
54 expected
= ['active', 'inactive', 'paused', 'composing', 'gone']
55 self
.failUnless(results
== expected
,
56 "Chat state event not handled: %s" % results
)
59 suite
= unittest
.TestLoader().loadTestsFromTestCase(TestStreamChatStates
)