Ignore:
Timestamp:
Jan 22, 2012, 2:51:25 PM (9 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Cleanups leading up to Wokkel 0.7.0.

As we now depend on Twisted 10.0.0 or higher, the following classes and
interfaces were deprecated:

This also resolves all Pyflakes warnings, changes links for www.xmpp.org to
xmpp.org and fixes the copyright notice in LICENSE to include 2012.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_subprotocols.py

    r101 r165  
    1414from twisted.python import failure
    1515from twisted.words.xish import domish
    16 from twisted.words.protocols.jabber import error, xmlstream
    17 
    18 from wokkel import generic, iwokkel, subprotocols
     16from twisted.words.protocols.jabber import error, ijabber, xmlstream
     17
     18from wokkel import generic, subprotocols
     19
     20class 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
    1951
    2052class DummyFactory(object):
     
    88120    def test_interface(self):
    89121        """
    90         L{xmlstream.XMPPHandler} implements L{iwokkel.IXMPPHandler}.
    91         """
    92         verifyObject(iwokkel.IXMPPHandler, subprotocols.XMPPHandler())
     122        L{xmlstream.XMPPHandler} implements L{ijabber.IXMPPHandler}.
     123        """
     124        verifyObject(ijabber.IXMPPHandler, subprotocols.XMPPHandler())
    93125
    94126
     
    155187        self.assertIdentical(request, handler.parent.requests[-1])
    156188        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)
    195189
    196190
     
    319313        handler = FailureReasonXMPPHandler()
    320314        handler.setHandlerParent(sm)
    321         xs = xmlstream.XmlStream(xmlstream.Authenticator())
     315        xmlstream.XmlStream(xmlstream.Authenticator())
    322316        sm._disconnected(failure.Failure(Exception("no reason")))
    323317        self.assertEquals(True, handler.gotFailureReason)
Note: See TracChangeset for help on using the changeset viewer.