Changeset 72:d48789c4c484
- Timestamp:
- Jul 21, 2009, 8:00:12 PM (13 years ago)
- Branch:
- default
- Convert:
- svn:b33ecbfc-034c-dc11-8662-000475d9059e/trunk@190
- Location:
- wokkel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
wokkel/client.py
r71 r72 80 80 81 81 82 82 83 class XMPPClient(StreamManager, service.Service): 83 84 """ … … 86 87 87 88 def __init__(self, jid, password, host=None, port=5222): 89 self.jid = jid 88 90 self.domain = jid.host 89 91 self.host = host … … 94 96 StreamManager.__init__(self, factory) 95 97 98 96 99 def startService(self): 97 100 service.Service.startService(self) 98 101 99 102 self._connection = self._getConnection() 103 100 104 101 105 def stopService(self): … … 104 108 self.factory.stopTrying() 105 109 self._connection.disconnect() 110 111 112 def _authd(self, xs): 113 """ 114 Called when the stream has been initialized. 115 116 Save the JID that we were assigned by the server, as the resource might 117 differ from the JID we asked for. This is stored on the authenticator 118 by its constituent initializers. 119 """ 120 self.jid = self.factory.authenticator.jid 121 StreamManager._authd(self, xs) 122 106 123 107 124 def initializationFailed(self, reason): … … 115 132 reason.raiseException() 116 133 134 117 135 def _getConnection(self): 118 136 if self.host: … … 122 140 c.connect() 123 141 return c 142 124 143 125 144 -
wokkel/test/test_client.py
r61 r72 21 21 from wokkel import client 22 22 from wokkel.test.test_compat import BootstrapMixinTest 23 24 class XMPPClientTest(unittest.TestCase): 25 """ 26 Tests for L{client.XMPPClient}. 27 """ 28 29 def setUp(self): 30 self.client = client.XMPPClient(JID('user@example.org'), 'secret') 31 32 33 def test_jid(self): 34 """ 35 Make sure the JID we pass is stored on the client. 36 """ 37 self.assertEquals(JID('user@example.org'), self.client.jid) 38 39 40 def test_jidWhenInitialized(self): 41 """ 42 Make sure that upon login, the JID is updated from the authenticator. 43 """ 44 xs = self.client.factory.buildProtocol(None) 45 self.client.factory.authenticator.jid = JID('user@example.org/test') 46 xs.dispatch(xs, xmlstream.STREAM_AUTHD_EVENT) 47 self.assertEquals(JID('user@example.org/test'), self.client.jid) 48 49 23 50 24 51 class DeferredClientFactoryTest(BootstrapMixinTest):
Note: See TracChangeset
for help on using the changeset viewer.