summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sleekxmpp/roster/item.py3
-rw-r--r--tests/test_stream_presence.py35
2 files changed, 35 insertions, 3 deletions
diff --git a/sleekxmpp/roster/item.py b/sleekxmpp/roster/item.py
index c27f7a78..4f4663d3 100644
--- a/sleekxmpp/roster/item.py
+++ b/sleekxmpp/roster/item.py
@@ -345,9 +345,10 @@ class RosterItem(object):
self.xmpp.event('got_online', presence)
if resource not in self.resources:
self.resources[resource] = {}
+ old_status = self.resources[resource].get('status', '')
old_show = self.resources[resource].get('show', None)
self.resources[resource].update(data)
- if old_show != presence['show']:
+ if old_show != presence['show'] or old_status != presence['status']:
self.xmpp.event('changed_status', presence)
def handle_unavailable(self, presence):
diff --git a/tests/test_stream_presence.py b/tests/test_stream_presence.py
index b7e6229c..63ccb043 100644
--- a/tests/test_stream_presence.py
+++ b/tests/test_stream_presence.py
@@ -337,13 +337,44 @@ class TestStreamPresence(SleekTest):
<presence from="user@example.com" to="tester@localhost" />
""")
+ self.recv("""
+ <presence from="user@example.com" to="tester@localhost" />
+ """)
+
+ # Changed status text, so fire new event
+ self.recv("""
+ <presence from="user@example.com" to="tester@localhost">
+ <status>Testing!</status>
+ </presence>
+ """)
+
+ # No change in show/status values, no event
+ self.recv("""
+ <presence from="user@example.com" to="tester@localhost">
+ <status>Testing!</status>
+ </presence>
+ """)
+
+ self.recv("""
+ <presence from="user@example.com" to="tester@localhost">
+ <show>dnd</show>
+ <status>Testing!</status>
+ </presence>
+ """)
+
+ self.recv("""
+ <presence from="user@example.com" to="tester@localhost">
+ <show>dnd</show>
+ <status>Testing!</status>
+ </presence>
+ """)
time.sleep(0.3)
self.assertEqual(events, ['available', 'away', 'dnd', 'chat',
- 'xa', 'unavailable', 'available'],
+ 'xa', 'unavailable', 'available',
+ 'available', 'dnd'],
"Changed status events incorrect: %s" % events)
-
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPresence)