Changeset 161:aecf77f1bb1f for wokkel


Ignore:
Timestamp:
Jan 8, 2012, 9:26:03 AM (8 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Allow empty MUC configuration forms to be sent.

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/muc.py

    r160 r161  
    104104            # This is a request for the configuration form.
    105105            form = None
    106         elif not self.options:
     106        elif self.options is False:
    107107            form = data_form.Form(formType='cancel')
    108108        else:
     
    757757        @type options: C{dict}
    758758        """
     759        if options is None:
     760            options = False
    759761        request = RegisterRequest(recipient=roomJID, options=options)
    760762        return self.request(request)
     
    838840        @type roomJID: L{jid.JID}
    839841
    840         @param options: A mapping of field names to values, or C{None} to cancel.
     842        @param options: A mapping of field names to values, or C{None} to
     843            cancel.
    841844        @type options: C{dict}
    842845        """
    843         if not options:
     846        if options is None:
    844847            options = False
    845848        request = ConfigureRequest(recipient=roomJID, options=options)
  • wokkel/test/test_muc.py

    r160 r161  
    880880
    881881
     882    def test_registerCancel(self):
     883        """
     884        Cancelling a registration request sends a cancel form.
     885        """
     886
     887        d = self.protocol.register(self.roomJID, None)
     888
     889        iq = self.stub.output[-1]
     890
     891        query = "/iq/query[@xmlns='%s']" % muc.NS_REGISTER
     892        nodes = xpath.queryForNodes(query, iq)
     893        self.assertNotIdentical(None, nodes, 'Invalid registration request')
     894
     895        form = data_form.findForm(nodes[0], muc.NS_MUC_REGISTER)
     896        self.assertNotIdentical(None, form, 'Missing registration form')
     897        self.assertEquals('cancel', form.formType)
     898
     899        response = toResponse(iq, 'result')
     900        self.stub.send(response)
     901        return d
     902
     903
    882904    def test_voice(self):
    883905        """
     
    10241046
    10251047
     1048    def test_configureEmpty(self):
     1049        """
     1050        Accept default configuration by sending an empty form.
     1051        """
     1052
     1053        values = {}
     1054
     1055        d = self.protocol.configure(self.roomJID, values)
     1056
     1057        iq = self.stub.output[-1]
     1058
     1059        query = "/iq/query[@xmlns='%s']" % (muc.NS_MUC_OWNER)
     1060        nodes = xpath.queryForNodes(query, iq)
     1061
     1062        form = data_form.findForm(nodes[0], muc.NS_MUC_CONFIG)
     1063        self.assertNotIdentical(None, form, 'Missing configuration form')
     1064        self.assertEquals('submit', form.formType)
     1065
     1066        response = toResponse(iq, 'result')
     1067        self.stub.send(response)
     1068        return d
     1069
     1070
    10261071    def test_configureCancel(self):
    10271072        """
Note: See TracChangeset for help on using the changeset viewer.