Changeset 189:8cb1f269c055


Ignore:
Timestamp:
Jul 10, 2013, 11:55:33 PM (7 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
hg-git-rename-source:
git
Message:

Do proper fallback for Request.stanzaType.

If stanzaType is not passed to the constructor of
wokkel.generic.Request, it should default to the value in the class
variable, not get.

Author: ralphm
Fixes: #80

Location:
wokkel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wokkel/generic.py

    r184 r185  
    275275    childParsers = {None: 'parseRequest'}
    276276
    277     def __init__(self, recipient=None, sender=None, stanzaType='get'):
     277    def __init__(self, recipient=None, sender=None, stanzaType=None):
    278278        Stanza.__init__(self, recipient=recipient, sender=sender)
    279         self.stanzaType = stanzaType
     279        if stanzaType is not None:
     280            self.stanzaType = stanzaType
    280281
    281282
  • wokkel/test/test_generic.py

    r184 r185  
    276276
    277277
     278    def test_stanzaTypeInit(self):
     279        """
     280        If stanzaType is passed in __init__, it overrides the class variable.
     281        """
     282
     283        class SetRequest(generic.Request):
     284            stanzaType = 'set'
     285
     286        request = SetRequest(stanzaType='get')
     287        self.assertEqual('get', request.stanzaType)
     288
     289
     290    def test_stanzaTypeClass(self):
     291        """
     292        If stanzaType is not passed in __init__, the class variable is used.
     293        """
     294
     295        class SetRequest(generic.Request):
     296            stanzaType = 'set'
     297
     298        request = SetRequest()
     299        self.assertEqual('set', request.stanzaType)
     300
     301
    278302
    279303class PrepareIDNNameTests(unittest.TestCase):
  • wokkel/test/test_muc.py

    r162 r185  
    13911391        iq = self.stub.output[-1]
    13921392
    1393         query = ("/iq/query[@xmlns='%s']/destroy[@xmlns='%s']" %
     1393        query = ("/iq[@type='set']/query[@xmlns='%s']/destroy[@xmlns='%s']" %
    13941394                 (muc.NS_MUC_OWNER, muc.NS_MUC_OWNER))
    13951395
Note: See TracChangeset for help on using the changeset viewer.