Ignore:
Timestamp:
Oct 10, 2008, 4:35:43 PM (14 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@88
Message:

Backport XmlStreamServerFactory?.

Author: ralphm.
Fixes #29.

This also replaces XmlStreamFactoryMixin? with BootstrapMixin? for DeferredClientFactory?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_compat.py

    r8 r34  
    1010from twisted.trial import unittest
    1111from twisted.words.xish import domish, utility
    12 from wokkel.compat import toResponse, XmlStreamFactoryMixin
     12from wokkel.compat import toResponse, BootstrapMixin
    1313
    1414class DummyProtocol(protocol.Protocol, utility.EventDispatcher):
     
    1616    I am a protocol with an event dispatcher without further processing.
    1717
    18     This protocol is only used for testing XmlStreamFactoryMixin to make
     18    This protocol is only used for testing BootstrapMixin to make
    1919    sure the bootstrap observers are added to the protocol instance.
    2020    """
     
    2828
    2929
    30 class XmlStreamFactoryMixinTest(unittest.TestCase):
    3130
    32     def test_buildProtocol(self):
     31class BootstrapMixinTest(unittest.TestCase):
     32    """
     33    Tests for L{BootstrapMixin}.
     34
     35    @ivar factory: Instance of the factory or mixin under test.
     36    """
     37
     38    def setUp(self):
     39        self.factory = BootstrapMixin()
     40
     41
     42    def test_installBootstraps(self):
    3343        """
    34         Test building of protocol.
    35 
    36         Arguments passed to Factory should be passed to protocol on
    37         instantiation. Bootstrap observers should be setup.
     44        Dispatching an event should fire registered bootstrap observers.
    3845        """
    3946        d = defer.Deferred()
     47        dispatcher = DummyProtocol()
     48        self.factory.addBootstrap('//event/myevent', d.callback)
     49        self.factory.installBootstraps(dispatcher)
     50        dispatcher.dispatch(None, '//event/myevent')
     51        return d
    4052
    41         f = XmlStreamFactoryMixin(None, test=None)
    42         f.protocol = DummyProtocol
    43         f.addBootstrap('//event/myevent', d.callback)
    44         xs = f.buildProtocol(None)
    45 
    46         self.assertEquals(f, xs.factory)
    47         self.assertEquals((None,), xs.args)
    48         self.assertEquals({'test': None}, xs.kwargs)
    49         xs.dispatch(None, '//event/myevent')
    50         return d
    5153
    5254    def test_addAndRemoveBootstrap(self):
     
    5759            pass
    5860
    59         f = XmlStreamFactoryMixin(None, test=None)
     61        self.factory.addBootstrap('//event/myevent', cb)
     62        self.assertIn(('//event/myevent', cb), self.factory.bootstraps)
    6063
    61         f.addBootstrap('//event/myevent', cb)
    62         self.assertIn(('//event/myevent', cb), f.bootstraps)
     64        self.factory.removeBootstrap('//event/myevent', cb)
     65        self.assertNotIn(('//event/myevent', cb), self.factory.bootstraps)
    6366
    64         f.removeBootstrap('//event/myevent', cb)
    65         self.assertNotIn(('//event/myevent', cb), f.bootstraps)
     67
    6668
    6769class ToResponseTest(unittest.TestCase):
Note: See TracChangeset for help on using the changeset viewer.