Changeset 148:75cf9e14b776 for wokkel/test/test_muc.py
- Timestamp:
- Aug 12, 2011, 3:57:20 PM (11 years ago)
- Branch:
- wokkel-muc-client-support-24
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/test/test_muc.py
r147 r148 20 20 from wokkel import data_form, iwokkel, muc 21 21 from wokkel.generic import parseXml 22 from wokkel.test.helpers import XmlStreamStub,TestableStreamManager22 from wokkel.test.helpers import TestableStreamManager 23 23 24 24 … … 590 590 591 591 592 def test_ roomConfigure(self):592 def test_configure(self): 593 593 """ 594 594 Default configure and changing the room name. … … 598 598 self.assertEquals('result', iq['type'], 'Not a result') 599 599 600 601 fields = [] 602 603 fields.append(data_form.Field(label='Natural-Language Room Name', 604 var='muc#roomconfig_roomname', 605 value=self.roomIdentifier)) 606 607 d = self.protocol.configure(self.roomJID, fields) 608 d.addCallback(cb) 609 610 iq = self.stub.output[-1] 611 query = "/iq/query[@xmlns='%s']/x"% muc.NS_MUC_OWNER 612 self.assertTrue(xpath.matches(query, iq), 'Bad configure request') 600 values = {'muc#roomconfig_roomname': self.roomIdentifier} 601 602 d = self.protocol.configure(self.roomJID, values) 603 d.addCallback(cb) 604 605 iq = self.stub.output[-1] 606 607 self.assertEquals('set', iq.getAttribute('type')) 608 self.assertEquals(self.roomJID.full(), iq.getAttribute('to')) 609 610 query = "/iq/query[@xmlns='%s']" % (muc.NS_MUC_OWNER) 611 nodes = xpath.queryForNodes(query, iq) 612 self.assertNotIdentical(None, nodes, 'Bad configure request') 613 614 form = data_form.findForm(nodes[0], muc.NS_MUC_CONFIG) 615 self.assertNotIdentical(None, form, 'Missing configuration form') 616 self.assertEquals('submit', form.formType) 613 617 614 618 response = toResponse(iq, 'result') 615 619 self.stub.send(response) 620 return d 621 622 623 def test_configureCancel(self): 624 """ 625 Cancelling room configuration should send a cancel form. 626 """ 627 628 d = self.protocol.configure(self.roomJID, None) 629 630 iq = self.stub.output[-1] 631 632 query = "/iq/query[@xmlns='%s']" % (muc.NS_MUC_OWNER) 633 nodes = xpath.queryForNodes(query, iq) 634 635 form = data_form.findForm(nodes[0], muc.NS_MUC_CONFIG) 636 self.assertNotIdentical(None, form, 'Missing configuration form') 637 self.assertEquals('cancel', form.formType) 638 639 response = toResponse(iq, 'result') 640 self.stub.send(response) 641 return d 642 643 644 def test_getConfiguration(self): 645 """ 646 The response of a configure form request should extract the form. 647 """ 648 649 def cb(form): 650 self.assertEquals('form', form.formType) 651 652 d = self.protocol.getConfiguration(self.roomJID) 653 d.addCallback(cb) 654 655 iq = self.stub.output[-1] 656 657 query = "/iq/query[@xmlns='%s']" % (muc.NS_MUC_OWNER) 658 nodes = xpath.queryForNodes(query, iq) 659 self.assertNotIdentical(None, nodes, 'Missing query element') 660 661 self.assertRaises(StopIteration, nodes[0].elements().next) 662 663 xml = u""" 664 <iq from='%s' id='%s' to='%s' type='result'> 665 <query xmlns='http://jabber.org/protocol/muc#owner'> 666 <x xmlns='jabber:x:data' type='form'> 667 <field type='hidden' 668 var='FORM_TYPE'> 669 <value>http://jabber.org/protocol/muc#roomconfig</value> 670 </field> 671 <field label='Natural-Language Room Name' 672 type='text-single' 673 var='muc#roomconfig_roomname'/> 674 </x> 675 </query> 676 </iq> 677 """ % (self.roomJID, iq['id'], self.userJID) 678 self.stub.send(parseXml(xml)) 679 680 return d 681 682 683 def test_getConfigurationNoOptions(self): 684 """ 685 The response of a configure form request should extract the form. 686 """ 687 688 def cb(form): 689 self.assertIdentical(None, form) 690 691 d = self.protocol.getConfiguration(self.roomJID) 692 d.addCallback(cb) 693 694 iq = self.stub.output[-1] 695 696 xml = u""" 697 <iq from='%s' id='%s' to='%s' type='result'> 698 <query xmlns='http://jabber.org/protocol/muc#owner'/> 699 </iq> 700 """ % (self.roomJID, iq['id'], self.userJID) 701 self.stub.send(parseXml(xml)) 702 616 703 return d 617 704
Note: See TracChangeset
for help on using the changeset viewer.