From 7522839141e7dd5bd081a421a58b0962b705fdda Mon Sep 17 00:00:00 2001 From: Nathan Fritz Date: Thu, 13 May 2010 09:07:20 +0800 Subject: added test for unsolicided unavailable presence and fixed bug to make it pass --- tests/test_presencestanzas.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/test_presencestanzas.py b/tests/test_presencestanzas.py index 430c71ca..23eb911e 100644 --- a/tests/test_presencestanzas.py +++ b/tests/test_presencestanzas.py @@ -11,5 +11,21 @@ class testpresencestanzas(unittest.TestCase): p = self.p.Presence() p['type'] = 'dnd' self.failUnless(str(p) == "dnd") + + def testPresenceUnsolicitedOffline(self): + "Unsolicted offline presence does not spawn changed_status or update roster" + p = self.p.Presence() + p['type'] = 'unavailable' + p['from'] = 'bill@chadmore.com/gmail15af' + import sleekxmpp + c = sleekxmpp.ClientXMPP('crap@wherever', 'password') + happened = [] + def handlechangedpresence(event): + happened.append(True) + c.add_event_handler("changed_status", handlechangedpresence) + c._handlePresence(p) + self.failUnless(happened == [], "changed_status event triggered for superfulous unavailable presence") + self.failUnless(c.roster == {}, "Roster updated for superfulous unavailable presence") + suite = unittest.TestLoader().loadTestsFromTestCase(testpresencestanzas) -- cgit v1.2.3