Changeset 38:b7c38c06f727 for wokkel/test/test_compat.py
- Timestamp:
- Oct 11, 2008, 9:43:57 PM (14 years ago)
- Branch:
- default
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@104
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/test/test_compat.py
r37 r38 7 7 """ 8 8 9 from zope.interface.verify import verifyObject 9 10 from twisted.internet import defer, protocol 11 from twisted.internet.interfaces import IProtocolFactory 10 12 from twisted.trial import unittest 11 13 from twisted.words.xish import domish, utility 12 from wokkel.compat import toResponse, BootstrapMixin 14 from twisted.words.protocols.jabber import xmlstream 15 from wokkel.compat import toResponse, BootstrapMixin, XmlStreamServerFactory 13 16 14 17 class DummyProtocol(protocol.Protocol, utility.EventDispatcher): … … 133 136 response = toResponse(stanza) 134 137 self.failIf(response.hasAttribute('type')) 138 139 140 141 class XmlStreamServerFactoryTest(BootstrapMixinTest): 142 """ 143 Tests for L{XmlStreamServerFactory}. 144 """ 145 146 def setUp(self): 147 """ 148 Set up a server factory with a authenticator factory function. 149 """ 150 def authenticatorFactory(): 151 return xmlstream.Authenticator() 152 153 self.factory = XmlStreamServerFactory(authenticatorFactory) 154 155 156 def test_interface(self): 157 """ 158 L{XmlStreamServerFactory} is a L{Factory}. 159 """ 160 verifyObject(IProtocolFactory, self.factory) 161 162 163 def test_buildProtocol(self): 164 """ 165 The authenticator factory should be passed to its protocol and it 166 should instantiate the authenticator and save it. 167 L{xmlstream.XmlStream}s do that, but we also want to ensure it really 168 is one. 169 """ 170 xs = self.factory.buildProtocol(None) 171 self.assertIdentical(self.factory, xs.factory) 172 self.assertIsInstance(xs, xmlstream.XmlStream) 173 self.assertIsInstance(xs.authenticator, xmlstream.Authenticator) 174 175 176 def test_buildProtocolTwice(self): 177 """ 178 Subsequent calls to buildProtocol should result in different instances 179 of the protocol, as well as their authenticators. 180 """ 181 xs1 = self.factory.buildProtocol(None) 182 xs2 = self.factory.buildProtocol(None) 183 self.assertNotIdentical(xs1, xs2) 184 self.assertNotIdentical(xs1.authenticator, xs2.authenticator)
Note: See TracChangeset
for help on using the changeset viewer.