| ... |
... |
@@ -9,12 +9,11 @@ lib.setup_env() |
|
9
|
9
|
from mock import Mock
|
|
10
|
10
|
|
|
11
|
11
|
from gajim.common.protocol.bytestream import ConnectionIBBytestream, ConnectionSocks5Bytestream
|
|
12
|
|
-from common.xmpp import dispatcher_nb
|
|
13
|
|
-from common.xmpp import protocol
|
|
|
12
|
+from nbxmpp import dispatcher_nb
|
|
|
13
|
+from nbxmpp import protocol
|
|
14
|
14
|
from gajim.common.jingle import ConnectionJingle
|
|
15
|
|
-from gajim.common import gajim
|
|
|
15
|
+from gajim.common import app
|
|
16
|
16
|
from gajim.common.socks5 import SocksQueue
|
|
17
|
|
-import gajim.common
|
|
18
|
17
|
|
|
19
|
18
|
|
|
20
|
19
|
session_init = '''
|
| ... |
... |
@@ -72,17 +71,17 @@ class Connection(Mock, ConnectionJingle, ConnectionSocks5Bytestream, |
|
72
|
71
|
ConnectionIBBytestream.__init__(self)
|
|
73
|
72
|
self.connected = 2 # This tells gajim we are connected
|
|
74
|
73
|
|
|
75
|
|
-
|
|
76
|
74
|
def send(self, stanza=None, when=None):
|
|
77
|
75
|
# Called when gajim wants to send something
|
|
78
|
76
|
print(str(stanza))
|
|
79
|
77
|
|
|
|
78
|
+
|
|
80
|
79
|
class TestJingle(unittest.TestCase):
|
|
81
|
80
|
|
|
82
|
81
|
def setUp(self):
|
|
83
|
82
|
self.dispatcher = dispatcher_nb.XMPPDispatcher()
|
|
84
|
|
- gajim.nec = Mock()
|
|
85
|
|
- gajim.socks5queue = SocksQueue(Mock())
|
|
|
83
|
+ app.nec = Mock()
|
|
|
84
|
+ app.socks5queue = SocksQueue(Mock())
|
|
86
|
85
|
# Setup mock client
|
|
87
|
86
|
self.client = Connection()
|
|
88
|
87
|
self.client.__str__ = lambda: 'Mock' # FIXME: why do I need this one?
|
| ... |
... |
@@ -99,10 +98,10 @@ class TestJingle(unittest.TestCase): |
|
99
|
98
|
a lot of places. It is easier to just copy it in here.
|
|
100
|
99
|
If the session_initiate stanza changes, this also must change.
|
|
101
|
100
|
'''
|
|
102
|
|
- self.recieve_file = {'stream-methods':
|
|
|
101
|
+ self.receive_file = {'stream-methods':
|
|
103
|
102
|
'http://jabber.org/protocol/bytestreams',
|
|
104
|
103
|
'sender': 'jtest@thiessen.im/Gajim',
|
|
105
|
|
- 'file-name': 'test_recieved_file',
|
|
|
104
|
+ 'file-name': 'test_received_file',
|
|
106
|
105
|
'request-id': '43', 'sid': '39',
|
|
107
|
106
|
'session-sid': '38', 'session-type': 'jingle',
|
|
108
|
107
|
'transfered_size': [], 'receiver':
|
| ... |
... |
@@ -132,26 +131,23 @@ class TestJingle(unittest.TestCase): |
|
132
|
131
|
|
|
133
|
132
|
def _simulate_jingle_session(self):
|
|
134
|
133
|
|
|
135
|
|
- self.dispatcher.RegisterHandler('iq', self.con._JingleCB, 'set'
|
|
136
|
|
- , common.xmpp.NS_JINGLE)
|
|
|
134
|
+ self.dispatcher.RegisterHandler('iq', self.con._JingleCB, 'set',
|
|
|
135
|
+ protocol.NS_JINGLE)
|
|
137
|
136
|
self.dispatcher.ProcessNonBlocking(session_init)
|
|
138
|
137
|
session = list(self.con._sessions.values())[0] # The only session we have
|
|
139
|
138
|
jft = list(session.contents.values())[0] # jingleFT object
|
|
140
|
|
- jft.file_props = self.recieve_file # We plug file_props manually
|
|
141
|
|
- # The user accepts to recieve the file
|
|
|
139
|
+ jft.file_props = self.receive_file # We plug file_props manually
|
|
|
140
|
+ # The user accepts to receive the file
|
|
142
|
141
|
# we have to manually simulate this behavior
|
|
143
|
142
|
session.approve_session()
|
|
144
|
|
- self.con.send_file_approval(self.recieve_file)
|
|
|
143
|
+ self.con.send_file_approval(self.receive_file)
|
|
145
|
144
|
|
|
146
|
145
|
self.dispatcher.ProcessNonBlocking(transport_info)
|
|
147
|
146
|
|
|
148
|
|
-
|
|
149
|
147
|
def test_jingle_session(self):
|
|
150
|
148
|
self._simulate_connect()
|
|
151
|
149
|
self._simulate_jingle_session()
|
|
152
|
150
|
|
|
153
|
151
|
|
|
154
|
|
-
|
|
155
|
|
-
|
|
156
|
152
|
if __name__ == '__main__':
|
|
157
|
153
|
unittest.main()
|