Changeset 34:5d34b8c88a55 for wokkel/test/test_compat.py
- Timestamp:
- Oct 10, 2008, 4:35:43 PM (14 years ago)
- Branch:
- default
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@88
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/test/test_compat.py
r8 r34 10 10 from twisted.trial import unittest 11 11 from twisted.words.xish import domish, utility 12 from wokkel.compat import toResponse, XmlStreamFactoryMixin12 from wokkel.compat import toResponse, BootstrapMixin 13 13 14 14 class DummyProtocol(protocol.Protocol, utility.EventDispatcher): … … 16 16 I am a protocol with an event dispatcher without further processing. 17 17 18 This protocol is only used for testing XmlStreamFactoryMixin to make18 This protocol is only used for testing BootstrapMixin to make 19 19 sure the bootstrap observers are added to the protocol instance. 20 20 """ … … 28 28 29 29 30 class XmlStreamFactoryMixinTest(unittest.TestCase):31 30 32 def test_buildProtocol(self): 31 class 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): 33 43 """ 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. 38 45 """ 39 46 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 40 52 41 f = XmlStreamFactoryMixin(None, test=None)42 f.protocol = DummyProtocol43 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 d51 53 52 54 def test_addAndRemoveBootstrap(self): … … 57 59 pass 58 60 59 f = XmlStreamFactoryMixin(None, test=None) 61 self.factory.addBootstrap('//event/myevent', cb) 62 self.assertIn(('//event/myevent', cb), self.factory.bootstraps) 60 63 61 f.addBootstrap('//event/myevent', cb)62 self.assert In(('//event/myevent', cb), f.bootstraps)64 self.factory.removeBootstrap('//event/myevent', cb) 65 self.assertNotIn(('//event/myevent', cb), self.factory.bootstraps) 63 66 64 f.removeBootstrap('//event/myevent', cb) 65 self.assertNotIn(('//event/myevent', cb), f.bootstraps) 67 66 68 67 69 class ToResponseTest(unittest.TestCase):
Note: See TracChangeset
for help on using the changeset viewer.