Changeset 165:76a61f5aa343 for wokkel/test/test_subprotocols.py
- Timestamp:
- Jan 22, 2012, 2:51:25 PM (11 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/test/test_subprotocols.py
r101 r165 14 14 from twisted.python import failure 15 15 from twisted.words.xish import domish 16 from twisted.words.protocols.jabber import error, xmlstream 17 18 from wokkel import generic, iwokkel, subprotocols 16 from twisted.words.protocols.jabber import error, ijabber, xmlstream 17 18 from wokkel import generic, subprotocols 19 20 class DeprecationTest(unittest.TestCase): 21 """ 22 Deprecation test for L{wokkel.subprotocols}. 23 """ 24 25 def lookForDeprecationWarning(self, testmethod, attributeName, newName): 26 """ 27 Importing C{testmethod} emits a deprecation warning. 28 """ 29 warningsShown = self.flushWarnings([testmethod]) 30 self.assertEqual(len(warningsShown), 1) 31 self.assertIdentical(warningsShown[0]['category'], DeprecationWarning) 32 self.assertEqual( 33 warningsShown[0]['message'], 34 "wokkel.subprotocols." + attributeName + " " 35 "was deprecated in Wokkel 0.7.0: Use " + newName + " instead.") 36 37 38 def test_xmppHandlerCollection(self): 39 """ 40 L{subprotocols.XMPPHandlerCollection} is deprecated. 41 """ 42 from wokkel.subprotocols import XMPPHandlerCollection 43 XMPPHandlerCollection 44 self.lookForDeprecationWarning( 45 self.test_xmppHandlerCollection, 46 "XMPPHandlerCollection", 47 "twisted.words.protocols.jabber.xmlstream." 48 "XMPPHandlerCollection") 49 50 19 51 20 52 class DummyFactory(object): … … 88 120 def test_interface(self): 89 121 """ 90 L{xmlstream.XMPPHandler} implements L{i wokkel.IXMPPHandler}.91 """ 92 verifyObject(i wokkel.IXMPPHandler, subprotocols.XMPPHandler())122 L{xmlstream.XMPPHandler} implements L{ijabber.IXMPPHandler}. 123 """ 124 verifyObject(ijabber.IXMPPHandler, subprotocols.XMPPHandler()) 93 125 94 126 … … 155 187 self.assertIdentical(request, handler.parent.requests[-1]) 156 188 return d 157 158 159 160 class XMPPHandlerCollectionTest(unittest.TestCase):161 """162 Tests for L{subprotocols.XMPPHandlerCollection}.163 """164 165 def setUp(self):166 self.collection = subprotocols.XMPPHandlerCollection()167 168 169 def test_interface(self):170 """171 L{subprotocols.StreamManager} implements L{iwokkel.IXMPPHandlerCollection}.172 """173 verifyObject(iwokkel.IXMPPHandlerCollection, self.collection)174 175 176 def test_addHandler(self):177 """178 Test the addition of a protocol handler.179 """180 handler = DummyXMPPHandler()181 handler.setHandlerParent(self.collection)182 self.assertIn(handler, self.collection)183 self.assertIdentical(self.collection, handler.parent)184 185 186 def test_removeHandler(self):187 """188 Test removal of a protocol handler.189 """190 handler = DummyXMPPHandler()191 handler.setHandlerParent(self.collection)192 handler.disownHandlerParent(self.collection)193 self.assertNotIn(handler, self.collection)194 self.assertIdentical(None, handler.parent)195 189 196 190 … … 319 313 handler = FailureReasonXMPPHandler() 320 314 handler.setHandlerParent(sm) 321 x s = xmlstream.XmlStream(xmlstream.Authenticator())315 xmlstream.XmlStream(xmlstream.Authenticator()) 322 316 sm._disconnected(failure.Failure(Exception("no reason"))) 323 317 self.assertEquals(True, handler.gotFailureReason)
Note: See TracChangeset
for help on using the changeset viewer.