'Test that got_offline is triggered properly.'

def testGotOffline(self):

    events = []
    def got_offline(presence):
        events.append('got_offline')
    self.xmpp.add_event_handler('got_offline', got_offline)
    self.recv('\n                                        <iq    type="set">\n                                                <query    xmlns="jabber:iq:roster">\n                                                        <item    jid="otheruser@localhost"\n                                                                                name="Other    User"\n                                                                                subscription="both">\n                                                                <group>Testers</group>\n                                                        </item>\n                                                </query>\n                                        </iq>\n                                ')
    self.recv('\n                                        <presence    from="otheruser@localhost/foobar"\n                                                                                to="tester@localhost"    />\n                                ')
    self.recv('\n                                        <presence    from="otheruser@localhost/foobar"\n                                                                                to="tester@localhost"\n                                                                                type="unavailable"    />\n                                ')
    time.sleep(0.1)
    self.assertEqual(events, ['got_offline'], ('Got    offline    incorrectly    triggered:    %s' % events))
