'Test handling pushed roster updates.'

def testRosterSet(self):

    self.stream_start(mode=u'client')
    events = []
    def roster_update(e):
        events.append(u'roster_update')
    self.xmpp.add_event_handler(u'roster_update', roster_update)
    self.recv(u'\n                                        <iq    to=\'tester@localhost\'    type="set"    id="1">\n                                                <query    xmlns="jabber:iq:roster">\n                                                        <item    jid="user@localhost"\n                                                                                name="User"\n                                                                                subscription="both">\n                                                                <group>Friends</group>\n                                                                <group>Examples</group>\n                                                        </item>\n                                                </query>\n                                        </iq>\n                                ')
    self.send(u'\n                                        <iq    type="result"    id="1">\n                                                <query    xmlns="jabber:iq:roster"    />\n                                        </iq>\n                                ')
    self.check_roster(u'tester@localhost', u'user@localhost', name=u'User', subscription=u'both', groups=[u'Friends', u'Examples'])
    time.sleep(0.1)
    self.failUnless((u'roster_update' in events), (u'Roster    updated    event    not    triggered:    %s' % events))
