source: ralphm-patches/request-xmpphandler.patch @ 47:f6d222b68f1c

Last change on this file since 47:f6d222b68f1c was 47:f6d222b68f1c, checked in by Ralph Meijer <ralphm@…>, 9 years ago

Many new patches, upstreamed affiliations and worked on pubsub item.
Upstreamed pubsub_manage_affiliations

File size: 2.2 KB
  • wokkel/subprotocols.py

    # HG changeset patch
    # Parent b05489ad4987a5e6263513c26048be801f7ce42b
    Add request method to XMPPHandler, passing up to its StreamManager.
    
    diff -r b05489ad4987 wokkel/subprotocols.py
    a b  
    9494        self.parent.send(obj)
    9595
    9696
     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)
     107
     108
    97109
    98110class XMPPHandlerCollection(object):
    99111    """
  • wokkel/test/test_subprotocols.py

    diff -r b05489ad4987 wokkel/test/test_subprotocols.py
    a b  
    7171
    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    """
    7685    Tests for L{subprotocols.XMPPHandler}.
     
    126135        self.assertIdentical(None, handler.xmlstream)
    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                d = 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):
    131161    """
     
    165195
    166196
    167197
    168 class IQGetStanza(generic.Stanza):
    169     timeout = None
    170 
    171     stanzaKind = 'iq'
    172     stanzaType = 'get'
    173     stanzaID = 'test'
    174 
    175 
    176 
    177198class StreamManagerTest(unittest.TestCase):
    178199    """
    179200    Tests for L{subprotocols.StreamManager}.
Note: See TracBrowser for help on using the repository browser.