Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
e95a7fcc
Commit
e95a7fcc
authored
6 years ago
by
André
Committed by
Philipp Hörist
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Test: Remove unused xmpp_mocks
parent
19a46070
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/integration/test_resolver.py
+0
-1
0 additions, 1 deletion
test/integration/test_resolver.py
test/lib/xmpp_mocks.py
+0
-94
0 additions, 94 deletions
test/lib/xmpp_mocks.py
with
0 additions
and
95 deletions
test/integration/test_resolver.py
+
0
−
1
View file @
e95a7fcc
...
...
@@ -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
'
JABBERCZ_TXT_NAME
=
'
_xmppconnect.jabber.cz
'
...
...
This diff is collapsed.
Click to expand it.
test/lib/xmpp_mocks.py
deleted
100644 → 0
+
0
−
94
View file @
19a46070
'''
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
):
self
.
iq
=
idlequeue
.
IdleQueue
()
self
.
stop
=
threading
.
Event
()
# Event to stop the thread main loop.
self
.
stop
.
clear
()
threading
.
Thread
.
__init__
(
self
)
def
run
(
self
):
while
not
self
.
stop
.
isSet
():
self
.
iq
.
process
()
time
.
sleep
(
IDLEQUEUE_INTERVAL
)
def
stop_thread
(
self
):
self
.
stop
.
set
()
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
()
self
.
_event
.
clear
()
def
wait
(
self
):
'''
Block until some callback sets the event and clearing the event
subsequently.
Returns True if event was set, False on timeout
'''
self
.
_event
.
wait
(
IDLEMOCK_TIMEOUT
)
if
self
.
_event
.
isSet
():
self
.
_event
.
clear
()
return
True
else
:
return
False
def
set_event
(
self
):
self
.
_event
.
set
()
class
MockConnection
(
IdleMock
,
Mock
):
'''
Class simulating Connection class from gajim/common/connection.py
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
IdleMock
.
__init__
(
self
)
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
self
.
set_event
()
def
on_auth
(
self
,
con
,
auth
):
'''
Method called after authentication, regardless of the result.
:Parameters:
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
self
.
set_event
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment