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_client.py

    r8 r34  
    77
    88from twisted.trial import unittest
     9from twisted.words.protocols.jabber import xmlstream
     10from twisted.words.protocols.jabber.client import XMPPAuthenticator
    911from twisted.words.protocols.jabber.jid import JID
    1012from twisted.words.protocols.jabber.xmlstream import STREAM_AUTHD_EVENT
     
    1214
    1315from wokkel.client import DeferredClientFactory
     16from wokkel.test.test_compat import BootstrapMixinTest
    1417
    15 class DeferredClientFactoryTest(unittest.TestCase):
     18class DeferredClientFactoryTest(BootstrapMixinTest):
     19
     20
     21    def setUp(self):
     22        self.factory = DeferredClientFactory(JID('user@example.org'), 'secret')
     23
     24
     25    def test_buildProtocol(self):
     26        """
     27        The authenticator factory should be passed to its protocol and it
     28        should instantiate the authenticator and save it.
     29        L{xmlstream.XmlStream}s do that, but we also want to ensure it really
     30        is one.
     31        """
     32        xs = self.factory.buildProtocol(None)
     33        self.assertIdentical(self.factory, xs.factory)
     34        self.assertIsInstance(xs, xmlstream.XmlStream)
     35        self.assertIsInstance(xs.authenticator, XMPPAuthenticator)
     36
    1637
    1738    def test_deferredOnInitialized(self):
     
    2041        """
    2142
    22         f = DeferredClientFactory(JID('user@example.org'), 'secret')
    23         xmlstream = f.buildProtocol(None)
    24         xmlstream.dispatch(xmlstream, STREAM_AUTHD_EVENT)
    25         return f.deferred
     43        xs = self.factory.buildProtocol(None)
     44        xs.dispatch(xs, STREAM_AUTHD_EVENT)
     45        return self.factory.deferred
     46
    2647
    2748    def test_deferredOnNotInitialized(self):
     
    3051        """
    3152
    32         f = DeferredClientFactory(JID('user@example.org'), 'secret')
    33         xmlstream = f.buildProtocol(None)
    34 
    3553        class TestException(Exception):
    3654            pass
    3755
    38         xmlstream.dispatch(TestException(), INIT_FAILED_EVENT)
    39         self.assertFailure(f.deferred, TestException)
    40         return f.deferred
     56        xs = self.factory.buildProtocol(None)
     57        xs.dispatch(TestException(), INIT_FAILED_EVENT)
     58        self.assertFailure(self.factory.deferred, TestException)
     59        return self.factory.deferred
     60
    4161
    4262    def test_deferredOnConnectionFailure(self):
     
    4565        """
    4666
    47         f = DeferredClientFactory(JID('user@example.org'), 'secret')
    48         xmlstream = f.buildProtocol(None)
    49 
    5067        class TestException(Exception):
    5168            pass
    5269
    53         f.clientConnectionFailed(self, TestException())
    54         self.assertFailure(f.deferred, TestException)
    55         return f.deferred
     70        xs = self.factory.buildProtocol(None)
     71        self.factory.clientConnectionFailed(self, TestException())
     72        self.assertFailure(self.factory.deferred, TestException)
     73        return self.factory.deferred
Note: See TracChangeset for help on using the changeset viewer.