diff options
author | Lance Stout <lancestout@gmail.com> | 2011-11-18 13:37:57 -0800 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2011-11-18 13:39:02 -0800 |
commit | 22868c3924529701dd8d86ba32a7c1752a3f6cb5 (patch) | |
tree | f735ccbfa5b4ea1c3b94a750b5993efe9cc5c135 /tests | |
parent | 2de1be188cf86e6ebb790938e276ecb85379a5b3 (diff) | |
download | slixmpp-22868c3924529701dd8d86ba32a7c1752a3f6cb5.tar.gz slixmpp-22868c3924529701dd8d86ba32a7c1752a3f6cb5.tar.bz2 slixmpp-22868c3924529701dd8d86ba32a7c1752a3f6cb5.tar.xz slixmpp-22868c3924529701dd8d86ba32a7c1752a3f6cb5.zip |
Fix changed_status event
Once again only fires when a resource's presence show value changes.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_stream_presence.py | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/tests/test_stream_presence.py b/tests/test_stream_presence.py index 21535dce..b7e6229c 100644 --- a/tests/test_stream_presence.py +++ b/tests/test_stream_presence.py @@ -251,5 +251,99 @@ class TestStreamPresence(SleekTest): self.assertEqual(events, ptypes, "Not all events raised: %s" % events) + def test_changed_status(self): + """Test that the changed_status event is handled properly.""" + events = [] + self.stream_start() + + def changed_status(presence): + events.append(presence['type']) + + self.xmpp.add_event_handler('changed_status', changed_status) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost" /> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost" /> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost"> + <show>away</show> + </presence> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost"> + <show>away</show> + </presence> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost"> + <show>dnd</show> + </presence> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost"> + <show>dnd</show> + </presence> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost"> + <show>chat</show> + </presence> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost"> + <show>chat</show> + </presence> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost"> + <show>xa</show> + </presence> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost"> + <show>xa</show> + </presence> + """) + + self.recv(""" + <presence from="user@example.com" + to="tester@localhost" + type="unavailable" /> + """) + + self.recv(""" + <presence from="user@example.com" + to="tester@localhost" + type="unavailable" /> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost" /> + """) + + self.recv(""" + <presence from="user@example.com" to="tester@localhost" /> + """) + + + time.sleep(0.3) + + self.assertEqual(events, ['available', 'away', 'dnd', 'chat', + 'xa', 'unavailable', 'available'], + "Changed status events incorrect: %s" % events) + + suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPresence) |