Changeset 101:d88462a49f86


Ignore:
Timestamp:
Aug 3, 2011, 9:49:22 AM (9 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Add request method to XMPPHandler, passing up to its StreamManager?.

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/subprotocols.py

    r100 r101  
    9393        """
    9494        self.parent.send(obj)
     95
     96
     97    def request(self, request):
     98        """
     99        Send an IQ request and track the response.
     100
     101        This passes the request to the parent for sending and response
     102        tracking.
     103
     104        @see: L{StreamManager.request}.
     105        """
     106        return self.parent.request(request)
    95107
    96108
  • wokkel/test/test_subprotocols.py

    r100 r101  
    7272
    7373
     74class IQGetStanza(generic.Stanza):
     75    timeout = None
     76
     77    stanzaKind = 'iq'
     78    stanzaType = 'get'
     79    stanzaID = 'test'
     80
     81
     82
    7483class XMPPHandlerTest(unittest.TestCase):
    7584    """
     
    127136
    128137
     138    def test_request(self):
     139        """
     140        A request is passed up to the stream manager.
     141        """
     142        class DummyStreamManager(object):
     143            def __init__(self):
     144                self.requests = []
     145
     146            def request(self, request):
     147                self.requests.append(request)
     148                return defer.succeed(None)
     149
     150        handler = subprotocols.XMPPHandler()
     151        handler.parent = DummyStreamManager()
     152        request = IQGetStanza()
     153        d = handler.request(request)
     154        self.assertEquals(1, len(handler.parent.requests))
     155        self.assertIdentical(request, handler.parent.requests[-1])
     156        return d
     157
     158
    129159
    130160class XMPPHandlerCollectionTest(unittest.TestCase):
     
    163193        self.assertNotIn(handler, self.collection)
    164194        self.assertIdentical(None, handler.parent)
    165 
    166 
    167 
    168 class IQGetStanza(generic.Stanza):
    169     stanzaKind = 'iq'
    170     stanzaType = 'get'
    171     stanzaID = 'test'
    172195
    173196
Note: See TracChangeset for help on using the changeset viewer.