Changeset 62:b98e610f62cc


Ignore:
Timestamp:
Jul 6, 2009, 9:24:58 AM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@174
Message:

Add sender parameter to disco requests.

Author: ralphm
Fixes #52.

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/disco.py

    r49 r62  
    374374    """
    375375
    376     def requestInfo(self, entity, nodeIdentifier=''):
     376    def requestInfo(self, entity, nodeIdentifier='', sender=None):
    377377        """
    378378        Request information discovery from a node.
     
    380380        @param entity: Entity to send the request to.
    381381        @type entity: L{jid.JID}
     382
    382383        @param nodeIdentifier: Optional node to request info from.
    383384        @type nodeIdentifier: C{unicode}
     385
     386        @param sender: Optional sender address.
     387        @type sender: L{jid.JID}
    384388        """
    385389
    386390        request = _DiscoRequest(self.xmlstream, NS_DISCO_INFO, nodeIdentifier)
     391        if sender is not None:
     392            request['from'] = unicode(sender)
    387393
    388394        d = request.send(entity.full())
     
    391397
    392398
    393     def requestItems(self, entity, nodeIdentifier=''):
     399    def requestItems(self, entity, nodeIdentifier='', sender=None):
    394400        """
    395401        Request items discovery from a node.
     
    397403        @param entity: Entity to send the request to.
    398404        @type entity: L{jid.JID}
     405
    399406        @param nodeIdentifier: Optional node to request info from.
    400407        @type nodeIdentifier: C{unicode}
     408
     409        @param sender: Optional sender address.
     410        @type sender: L{jid.JID}
    401411        """
    402412
    403413        request = _DiscoRequest(self.xmlstream, NS_DISCO_ITEMS, nodeIdentifier)
     414        if sender is not None:
     415            request['from'] = unicode(sender)
    404416
    405417        d = request.send(entity.full())
  • wokkel/test/test_disco.py

    r53 r62  
    515515
    516516
     517    def test_requestItemsFrom(self):
     518        """
     519        A disco items request can be sent with an explicit sender address.
     520        """
     521        d = self.protocol.requestItems(JID(u'example.org'),
     522                                       sender=JID(u'test.example.org'))
     523
     524        iq = self.stub.output[-1]
     525        self.assertEqual(u'test.example.org', iq.getAttribute(u'from'))
     526
     527        response = toResponse(iq, u'result')
     528        query = response.addElement((NS_DISCO_ITEMS, u'query'))
     529        self.stub.send(response)
     530
     531        return d
     532
     533
    517534    def test_requestInfo(self):
    518535        """
     
    550567
    551568        self.stub.send(response)
     569        return d
     570
     571
     572    def test_requestInfoFrom(self):
     573        """
     574        A disco info request can be sent with an explicit sender address.
     575        """
     576        d = self.protocol.requestInfo(JID(u'example.org'),
     577                                       sender=JID(u'test.example.org'))
     578
     579        iq = self.stub.output[-1]
     580        print iq.toXml()
     581        self.assertEqual(u'test.example.org', iq.getAttribute(u'from'))
     582
     583        response = toResponse(iq, u'result')
     584        query = response.addElement((NS_DISCO_INFO, u'query'))
     585        self.stub.send(response)
     586
    552587        return d
    553588
Note: See TracChangeset for help on using the changeset viewer.