'Test sending a disco#items query to another entity
and receiving the result.'

def testGetItemsRemote(self):

    self.stream_start(mode='client', plugins=['xep_0030'])
    events = set()
    results = set()
    def handle_disco_items(iq):
        events.add('disco_items')
        results.update(iq['disco_items']['items'])
    self.xmpp.add_event_handler('disco_items', handle_disco_items)
    t = threading.Thread(name='get_items', target=self.xmpp['xep_0030'].get_items, args=('user@localhost', 'foo'))
    t.start()
    self.send('\n                                        <iq    type="get"    to="user@localhost"    id="1">\n                                                <query    xmlns="http://jabber.org/protocol/disco#items"\n                                                                            node="foo"    />\n                                        </iq>\n                                ')
    self.recv('\n                                        <iq    type="result"    to="tester@localhost"    id="1">\n                                                <query    xmlns="http://jabber.org/protocol/disco#items"\n                                                                            node="foo">\n                                                        <item    jid="user@localhost"    node="bar"    name="Test"    />\n                                                        <item    jid="user@localhost"    node="baz"    name="Test    2"    />\n                                                </query>\n                                        </iq>\n                                ')
    t.join()
    time.sleep(0.1)
    items = set([('user@localhost', 'bar', 'Test'), ('user@localhost', 'baz', 'Test    2')])
    self.assertEqual(events, set(('disco_items',)), ('Disco    items    event    was    not    triggered:    %s' % events))
    self.assertEqual(results, items, ('Unexpected    items:    %s' % results))
