Changeset 58:a8c2aadabebd
- Timestamp:
- Apr 22, 2009, 5:02:49 PM (13 years ago)
- Branch:
- default
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@170
- Location:
- wokkel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/pubsub.py
r57 r58 625 625 626 626 627 def createNode(self, service, nodeIdentifier=None ):627 def createNode(self, service, nodeIdentifier=None, sender=None): 628 628 """ 629 629 Create a publish subscribe node. … … 637 637 request.recipient = service 638 638 request.nodeIdentifier = nodeIdentifier 639 request.sender = sender 639 640 640 641 def cb(iq): … … 651 652 652 653 653 def deleteNode(self, service, nodeIdentifier ):654 def deleteNode(self, service, nodeIdentifier, sender=None): 654 655 """ 655 656 Delete a publish subscribe node. … … 663 664 request.recipient = service 664 665 request.nodeIdentifier = nodeIdentifier 666 request.sender = sender 665 667 return request.send(self.xmlstream) 666 668 667 669 668 def subscribe(self, service, nodeIdentifier, subscriber ):670 def subscribe(self, service, nodeIdentifier, subscriber, sender=None): 669 671 """ 670 672 Subscribe to a publish subscribe node. … … 682 684 request.nodeIdentifier = nodeIdentifier 683 685 request.subscriber = subscriber 686 request.sender = sender 684 687 685 688 def cb(iq): … … 701 704 702 705 703 def unsubscribe(self, service, nodeIdentifier, subscriber ):706 def unsubscribe(self, service, nodeIdentifier, subscriber, sender=None): 704 707 """ 705 708 Unsubscribe from a publish subscribe node. … … 716 719 request.nodeIdentifier = nodeIdentifier 717 720 request.subscriber = subscriber 721 request.sender = sender 718 722 return request.send(self.xmlstream) 719 723 720 724 721 def publish(self, service, nodeIdentifier, items=None ):725 def publish(self, service, nodeIdentifier, items=None, sender=None): 722 726 """ 723 727 Publish to a publish subscribe node. … … 734 738 request.nodeIdentifier = nodeIdentifier 735 739 request.items = items 740 request.sender = sender 736 741 return request.send(self.xmlstream) 737 742 738 743 739 def items(self, service, nodeIdentifier, maxItems=None ):744 def items(self, service, nodeIdentifier, maxItems=None, sender=None): 740 745 """ 741 746 Retrieve previously published items from a publish subscribe node. … … 753 758 if maxItems: 754 759 request.maxItems = str(int(maxItems)) 760 request.sender = sender 755 761 756 762 def cb(iq): -
wokkel/test/test_pubsub.py
r57 r58 256 256 257 257 258 def test_createNodeWithSender(self): 259 """ 260 Test sending create request from a specific JID. 261 """ 262 263 d = self.protocol.createNode(JID('pubsub.example.org'), 'test', 264 sender=JID('user@example.org')) 265 266 iq = self.stub.output[-1] 267 self.assertEquals('user@example.org', iq['from']) 268 269 response = toResponse(iq, 'result') 270 self.stub.send(response) 271 return d 272 273 258 274 def test_deleteNode(self): 259 275 """ … … 273 289 child = children[0] 274 290 self.assertEquals('test', child['node']) 291 292 response = toResponse(iq, 'result') 293 self.stub.send(response) 294 return d 295 296 297 def test_deleteNodeWithSender(self): 298 """ 299 Test sending delete request. 300 """ 301 302 d = self.protocol.deleteNode(JID('pubsub.example.org'), 'test', 303 sender=JID('user@example.org')) 304 305 iq = self.stub.output[-1] 306 self.assertEquals('user@example.org', iq['from']) 275 307 276 308 response = toResponse(iq, 'result') … … 330 362 331 363 364 def test_publishWithSender(self): 365 """ 366 Test sending publish request from a specific JID. 367 """ 368 369 item = pubsub.Item() 370 d = self.protocol.publish(JID('pubsub.example.org'), 'test', [item], 371 JID('user@example.org')) 372 373 iq = self.stub.output[-1] 374 self.assertEquals('user@example.org', iq['from']) 375 376 response = toResponse(iq, 'result') 377 self.stub.send(response) 378 return d 379 380 332 381 def test_subscribe(self): 333 382 """ … … 399 448 400 449 450 def test_subscribeWithSender(self): 451 """ 452 Test sending subscription request from a specific JID. 453 """ 454 d = self.protocol.subscribe(JID('pubsub.example.org'), 'test', 455 JID('user@example.org'), 456 sender=JID('user@example.org')) 457 458 iq = self.stub.output[-1] 459 self.assertEquals('user@example.org', iq['from']) 460 461 response = toResponse(iq, 'result') 462 pubsub = response.addElement((NS_PUBSUB, 'pubsub')) 463 subscription = pubsub.addElement('subscription') 464 subscription['node'] = 'test' 465 subscription['jid'] = 'user@example.org' 466 subscription['subscription'] = 'subscribed' 467 self.stub.send(response) 468 return d 469 470 401 471 def test_unsubscribe(self): 402 472 """ … … 422 492 423 493 494 def test_unsubscribeWithSender(self): 495 """ 496 Test sending unsubscription request from a specific JID. 497 """ 498 d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test', 499 JID('user@example.org'), 500 sender=JID('user@example.org')) 501 502 iq = self.stub.output[-1] 503 self.assertEquals('user@example.org', iq['from']) 504 self.stub.send(toResponse(iq, 'result')) 505 return d 506 507 424 508 def test_items(self): 425 509 """ … … 485 569 self.stub.send(response) 486 570 571 return d 572 573 574 def test_itemsWithSender(self): 575 """ 576 Test sending items request from a specific JID. 577 """ 578 579 d = self.protocol.items(JID('pubsub.example.org'), 'test', 580 sender=JID('user@example.org')) 581 582 iq = self.stub.output[-1] 583 self.assertEquals('user@example.org', iq['from']) 584 585 response = toResponse(iq, 'result') 586 items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items') 587 items['node'] = 'test' 588 589 self.stub.send(response) 487 590 return d 488 591
Note: See TracChangeset
for help on using the changeset viewer.