Changeset 42:93675ba90f36


Ignore:
Timestamp:
Oct 24, 2008, 2:40:48 PM (13 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Convert:
svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@126
Message:

Change clientCreator to use the JID passed to the factory correctly.

Author: ralphm
Fixes #37.

Location:
wokkel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wokkel/client.py

    r34 r42  
    182182
    183183def clientCreator(factory):
    184     domain = factory.authenticator.jid.host
     184    domain = factory.jid.host
    185185    c = SRVConnector(reactor, 'xmpp-client', domain, factory)
    186186    c.connect()
  • wokkel/test/test_client.py

    r36 r42  
    66"""
    77
     8from twisted.internet import defer
     9from twisted.trial import unittest
    810from twisted.words.protocols.jabber import xmlstream
    911from twisted.words.protocols.jabber.client import XMPPAuthenticator
     
    1214from twisted.words.protocols.jabber.xmlstream import INIT_FAILED_EVENT
    1315
    14 from wokkel.client import DeferredClientFactory
     16from wokkel import client
    1517from wokkel.test.test_compat import BootstrapMixinTest
    1618
    1719class DeferredClientFactoryTest(BootstrapMixinTest):
    18 
     20    """
     21    Tests for L{client.DeferredClientFactory}.
     22    """
    1923
    2024    def setUp(self):
    21         self.factory = DeferredClientFactory(JID('user@example.org'), 'secret')
     25        self.factory = client.DeferredClientFactory(JID('user@example.org'),
     26                                                    'secret')
    2227
    2328
     
    7176        self.assertFailure(self.factory.deferred, TestException)
    7277        return self.factory.deferred
     78
     79
     80
     81class ClientCreatorTest(unittest.TestCase):
     82    """
     83    Tests for L{client.clientCreator}.
     84    """
     85
     86    def test_call(self):
     87        """
     88        The factory is passed to an SRVConnector and a connection initiated.
     89        """
     90
     91        d1 = defer.Deferred()
     92        factory = client.DeferredClientFactory(JID('user@example.org'),
     93                                               'secret')
     94
     95        def cb(connector):
     96            self.assertEqual('xmpp-client', connector.service)
     97            self.assertEqual('example.org', connector.domain)
     98            self.assertEqual(factory, connector.factory)
     99
     100        def connect(connector):
     101            d1.callback(connector)
     102
     103        d1.addCallback(cb)
     104        self.patch(client.SRVConnector, 'connect', connect)
     105
     106        d2 = client.clientCreator(factory)
     107        self.assertEqual(factory.deferred, d2)
     108
     109        return d1
Note: See TracChangeset for help on using the changeset viewer.