mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-27 11:09:56 +00:00
Also fire changed_status when the status text changes for a resource.
This commit is contained in:
parent
22868c3924
commit
d4c1ff5309
2 changed files with 35 additions and 3 deletions
|
@ -345,9 +345,10 @@ class RosterItem(object):
|
||||||
self.xmpp.event('got_online', presence)
|
self.xmpp.event('got_online', presence)
|
||||||
if resource not in self.resources:
|
if resource not in self.resources:
|
||||||
self.resources[resource] = {}
|
self.resources[resource] = {}
|
||||||
|
old_status = self.resources[resource].get('status', '')
|
||||||
old_show = self.resources[resource].get('show', None)
|
old_show = self.resources[resource].get('show', None)
|
||||||
self.resources[resource].update(data)
|
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)
|
self.xmpp.event('changed_status', presence)
|
||||||
|
|
||||||
def handle_unavailable(self, presence):
|
def handle_unavailable(self, presence):
|
||||||
|
|
|
@ -337,13 +337,44 @@ class TestStreamPresence(SleekTest):
|
||||||
<presence from="user@example.com" to="tester@localhost" />
|
<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)
|
time.sleep(0.3)
|
||||||
|
|
||||||
self.assertEqual(events, ['available', 'away', 'dnd', 'chat',
|
self.assertEqual(events, ['available', 'away', 'dnd', 'chat',
|
||||||
'xa', 'unavailable', 'available'],
|
'xa', 'unavailable', 'available',
|
||||||
|
'available', 'dnd'],
|
||||||
"Changed status events incorrect: %s" % events)
|
"Changed status events incorrect: %s" % events)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPresence)
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamPresence)
|
||||||
|
|
Loading…
Reference in a new issue