Tests: fix imports
This commit is contained in:
parent
c49f9d60ab
commit
38218aced1
|
@ -9,7 +9,6 @@ from gi.repository import GLib
|
||||||
|
|
||||||
from gajim.common import resolver
|
from gajim.common import resolver
|
||||||
|
|
||||||
from mock import Mock, expectParams
|
|
||||||
from gajim_mocks import *
|
from gajim_mocks import *
|
||||||
from xmpp_mocks import IdleQueueThread
|
from xmpp_mocks import IdleQueueThread
|
||||||
|
|
||||||
|
|
|
@ -55,5 +55,5 @@ def setup_env():
|
||||||
if use_x:
|
if use_x:
|
||||||
from gajim import gtkgui_helpers
|
from gajim import gtkgui_helpers
|
||||||
gtkgui_helpers.GUI_DIR = gajim_root + '/gajim/data/gui'
|
gtkgui_helpers.GUI_DIR = gajim_root + '/gajim/data/gui'
|
||||||
from gajim.gajim import GajimApplication
|
from gajim.application import GajimApplication
|
||||||
app.app = GajimApplication()
|
app.app = GajimApplication()
|
||||||
|
|
|
@ -9,12 +9,11 @@ lib.setup_env()
|
||||||
from mock import Mock
|
from mock import Mock
|
||||||
|
|
||||||
from gajim.common.protocol.bytestream import ConnectionIBBytestream, ConnectionSocks5Bytestream
|
from gajim.common.protocol.bytestream import ConnectionIBBytestream, ConnectionSocks5Bytestream
|
||||||
from common.xmpp import dispatcher_nb
|
from nbxmpp import dispatcher_nb
|
||||||
from common.xmpp import protocol
|
from nbxmpp import protocol
|
||||||
from gajim.common.jingle import ConnectionJingle
|
from gajim.common.jingle import ConnectionJingle
|
||||||
from gajim.common import gajim
|
from gajim.common import app
|
||||||
from gajim.common.socks5 import SocksQueue
|
from gajim.common.socks5 import SocksQueue
|
||||||
import gajim.common
|
|
||||||
|
|
||||||
|
|
||||||
session_init = '''
|
session_init = '''
|
||||||
|
@ -72,17 +71,17 @@ class Connection(Mock, ConnectionJingle, ConnectionSocks5Bytestream,
|
||||||
ConnectionIBBytestream.__init__(self)
|
ConnectionIBBytestream.__init__(self)
|
||||||
self.connected = 2 # This tells gajim we are connected
|
self.connected = 2 # This tells gajim we are connected
|
||||||
|
|
||||||
|
|
||||||
def send(self, stanza=None, when=None):
|
def send(self, stanza=None, when=None):
|
||||||
# Called when gajim wants to send something
|
# Called when gajim wants to send something
|
||||||
print(str(stanza))
|
print(str(stanza))
|
||||||
|
|
||||||
|
|
||||||
class TestJingle(unittest.TestCase):
|
class TestJingle(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.dispatcher = dispatcher_nb.XMPPDispatcher()
|
self.dispatcher = dispatcher_nb.XMPPDispatcher()
|
||||||
gajim.nec = Mock()
|
app.nec = Mock()
|
||||||
gajim.socks5queue = SocksQueue(Mock())
|
app.socks5queue = SocksQueue(Mock())
|
||||||
# Setup mock client
|
# Setup mock client
|
||||||
self.client = Connection()
|
self.client = Connection()
|
||||||
self.client.__str__ = lambda: 'Mock' # FIXME: why do I need this one?
|
self.client.__str__ = lambda: 'Mock' # FIXME: why do I need this one?
|
||||||
|
@ -99,10 +98,10 @@ class TestJingle(unittest.TestCase):
|
||||||
a lot of places. It is easier to just copy it in here.
|
a lot of places. It is easier to just copy it in here.
|
||||||
If the session_initiate stanza changes, this also must change.
|
If the session_initiate stanza changes, this also must change.
|
||||||
'''
|
'''
|
||||||
self.recieve_file = {'stream-methods':
|
self.receive_file = {'stream-methods':
|
||||||
'http://jabber.org/protocol/bytestreams',
|
'http://jabber.org/protocol/bytestreams',
|
||||||
'sender': 'jtest@thiessen.im/Gajim',
|
'sender': 'jtest@thiessen.im/Gajim',
|
||||||
'file-name': 'test_recieved_file',
|
'file-name': 'test_received_file',
|
||||||
'request-id': '43', 'sid': '39',
|
'request-id': '43', 'sid': '39',
|
||||||
'session-sid': '38', 'session-type': 'jingle',
|
'session-sid': '38', 'session-type': 'jingle',
|
||||||
'transfered_size': [], 'receiver':
|
'transfered_size': [], 'receiver':
|
||||||
|
@ -132,26 +131,23 @@ class TestJingle(unittest.TestCase):
|
||||||
|
|
||||||
def _simulate_jingle_session(self):
|
def _simulate_jingle_session(self):
|
||||||
|
|
||||||
self.dispatcher.RegisterHandler('iq', self.con._JingleCB, 'set'
|
self.dispatcher.RegisterHandler('iq', self.con._JingleCB, 'set',
|
||||||
, common.xmpp.NS_JINGLE)
|
protocol.NS_JINGLE)
|
||||||
self.dispatcher.ProcessNonBlocking(session_init)
|
self.dispatcher.ProcessNonBlocking(session_init)
|
||||||
session = list(self.con._sessions.values())[0] # The only session we have
|
session = list(self.con._sessions.values())[0] # The only session we have
|
||||||
jft = list(session.contents.values())[0] # jingleFT object
|
jft = list(session.contents.values())[0] # jingleFT object
|
||||||
jft.file_props = self.recieve_file # We plug file_props manually
|
jft.file_props = self.receive_file # We plug file_props manually
|
||||||
# The user accepts to recieve the file
|
# The user accepts to receive the file
|
||||||
# we have to manually simulate this behavior
|
# we have to manually simulate this behavior
|
||||||
session.approve_session()
|
session.approve_session()
|
||||||
self.con.send_file_approval(self.recieve_file)
|
self.con.send_file_approval(self.receive_file)
|
||||||
|
|
||||||
self.dispatcher.ProcessNonBlocking(transport_info)
|
self.dispatcher.ProcessNonBlocking(transport_info)
|
||||||
|
|
||||||
|
|
||||||
def test_jingle_session(self):
|
def test_jingle_session(self):
|
||||||
self._simulate_connect()
|
self._simulate_connect()
|
||||||
self._simulate_jingle_session()
|
self._simulate_jingle_session()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -13,13 +13,12 @@ from gajim.common import nec
|
||||||
from gajim.common import ged
|
from gajim.common import ged
|
||||||
from gajim.common.nec import NetworkEvent
|
from gajim.common.nec import NetworkEvent
|
||||||
from gajim.common.modules.message import MessageReceivedEvent
|
from gajim.common.modules.message import MessageReceivedEvent
|
||||||
from gajim.common.connection_handlers_events import DecryptedMessageReceivedEvent
|
from gajim.common.modules.message import DecryptedMessageReceivedEvent
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
|
|
||||||
from gajim.session import ChatControlSession
|
from gajim.session import ChatControlSession
|
||||||
from gajim.roster_window import RosterWindow
|
from gajim.roster_window import RosterWindow
|
||||||
|
|
||||||
from mock import Mock, expectParams
|
|
||||||
from gajim_mocks import *
|
from gajim_mocks import *
|
||||||
from data import account1
|
from data import account1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue