Changeset 62:b98e610f62cc
- Timestamp:
- Jul 6, 2009, 9:24:58 AM (13 years ago)
- Branch:
- default
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@174
- Location:
- wokkel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/disco.py
r49 r62 374 374 """ 375 375 376 def requestInfo(self, entity, nodeIdentifier='' ):376 def requestInfo(self, entity, nodeIdentifier='', sender=None): 377 377 """ 378 378 Request information discovery from a node. … … 380 380 @param entity: Entity to send the request to. 381 381 @type entity: L{jid.JID} 382 382 383 @param nodeIdentifier: Optional node to request info from. 383 384 @type nodeIdentifier: C{unicode} 385 386 @param sender: Optional sender address. 387 @type sender: L{jid.JID} 384 388 """ 385 389 386 390 request = _DiscoRequest(self.xmlstream, NS_DISCO_INFO, nodeIdentifier) 391 if sender is not None: 392 request['from'] = unicode(sender) 387 393 388 394 d = request.send(entity.full()) … … 391 397 392 398 393 def requestItems(self, entity, nodeIdentifier='' ):399 def requestItems(self, entity, nodeIdentifier='', sender=None): 394 400 """ 395 401 Request items discovery from a node. … … 397 403 @param entity: Entity to send the request to. 398 404 @type entity: L{jid.JID} 405 399 406 @param nodeIdentifier: Optional node to request info from. 400 407 @type nodeIdentifier: C{unicode} 408 409 @param sender: Optional sender address. 410 @type sender: L{jid.JID} 401 411 """ 402 412 403 413 request = _DiscoRequest(self.xmlstream, NS_DISCO_ITEMS, nodeIdentifier) 414 if sender is not None: 415 request['from'] = unicode(sender) 404 416 405 417 d = request.send(entity.full()) -
wokkel/test/test_disco.py
r53 r62 515 515 516 516 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 517 534 def test_requestInfo(self): 518 535 """ … … 550 567 551 568 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 552 587 return d 553 588
Note: See TracChangeset
for help on using the changeset viewer.