Commit e95a7fcc authored by André's avatar André Committed by Philipp Hörist

Test: Remove unused xmpp_mocks

parent 19a46070
......@@ -10,7 +10,6 @@ from gi.repository import GLib
from gajim.common import resolver
from gajim_mocks import *
from xmpp_mocks import IdleQueueThread
NONSENSE_NAME = 'sfsdfsdfsdf.sdfs.fsd'
Module with dummy classes for unit testing of XMPP and related code.
import threading, time
from mock import Mock
from nbxmpp import idlequeue
IDLEQUEUE_INTERVAL = 0.2 # polling interval. 200ms is used in Gajim as default
IDLEMOCK_TIMEOUT = 30 # how long we wait for an event
class IdleQueueThread(threading.Thread):
Thread for regular processing of idlequeue.
def __init__(self): = idlequeue.IdleQueue()
self.stop = threading.Event() # Event to stop the thread main loop.
def run(self):
while not self.stop.isSet():
def stop_thread(self):
class IdleMock:
Serves as template for testing objects that are normally controlled by GUI.
Allows to wait for asynchronous callbacks with wait() method.
def __init__(self):
self._event = threading.Event()
def wait(self):
Block until some callback sets the event and clearing the event
Returns True if event was set, False on timeout
if self._event.isSet():
return True
return False
def set_event(self):
class MockConnection(IdleMock, Mock):
Class simulating Connection class from gajim/common/
It is derived from Mock in order to avoid defining all methods
from real Connection that are called from NBClient or Dispatcher
( _event_dispatcher for example)
def __init__(self, *args):
self.connect_succeeded = True
Mock.__init__(self, *args)
def on_connect(self, success, *args):
Method called after connecting - after receiving <stream:features>
from server (NOT after TLS stream restart) or connect failure
self.connect_succeeded = success
def on_auth(self, con, auth):
Method called after authentication, regardless of the result.
con : NonBlockingClient
reference to authenticated object
auth : string
type of authetication in case of success ('old_auth', 'sasl') or
None in case of auth failure
self.auth_connection = con
self.auth = auth
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment