summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-11-30 17:42:57 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-12-01 10:39:49 +0000
commit5c395b47ac277179fafb153340656598c7348bf8 (patch)
tree79cf5eb9451a41170d3d625b482c38203433cdcd
parentbc4710f906268330ae83c34f981c5245c1b57227 (diff)
downloadtelepathy-haze-5c395b47ac277179fafb153340656598c7348bf8.tar.gz
Add close_all_groups() and use it to get rid of any stray groups
The group tests are sensitive to leftover groups that might exist in global libpurple state.
-rw-r--r--tests/twisted/hazetest.py10
-rw-r--r--tests/twisted/roster/groups.py6
-rw-r--r--tests/twisted/roster/publish.py6
-rw-r--r--tests/twisted/roster/subscribe.py6
4 files changed, 25 insertions, 3 deletions
diff --git a/tests/twisted/hazetest.py b/tests/twisted/hazetest.py
index c179309..2c43b53 100644
--- a/tests/twisted/hazetest.py
+++ b/tests/twisted/hazetest.py
@@ -792,3 +792,13 @@ def make_presence(_from, to='test@localhost', type=None, show=None,
x.addElement('photo').addContent(photo)
return presence
+
+def close_all_groups(q, bus, conn, stream):
+ channels = conn.Properties.Get(cs.CONN_IFACE_REQUESTS, 'Channels')
+ for path, props in channels:
+ if props.get(cs.CHANNEL_TYPE) != cs.CHANNEL_TYPE_CONTACT_LIST:
+ continue
+ if props.get(cs.TARGET_HANDLE_TYPE) != cs.HT_GROUP:
+ continue
+ wrap_channel(bus.get_object(conn.bus_name, path),
+ cs.CHANNEL_TYPE_CONTACT_LIST).Close()
diff --git a/tests/twisted/roster/groups.py b/tests/twisted/roster/groups.py
index 0e5e137..9d7dff6 100644
--- a/tests/twisted/roster/groups.py
+++ b/tests/twisted/roster/groups.py
@@ -9,7 +9,7 @@ from twisted.words.xish import domish, xpath
from servicetest import (EventPattern, wrap_channel, assertLength,
assertEquals, call_async, sync_dbus, assertContains)
-from hazetest import acknowledge_iq, exec_test, sync_stream
+from hazetest import acknowledge_iq, exec_test, sync_stream, close_all_groups
import constants as cs
import ns
@@ -18,6 +18,10 @@ def test(q, bus, conn, stream):
q.expect('dbus-signal', signal='StatusChanged',
args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
+ # Close all Group channels to get a clean slate, so we can rely on
+ # the NewChannels signal for the default group later
+ close_all_groups(q, bus, conn, stream)
+
call_async(q, conn.Requests, 'EnsureChannel',{
cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST,
cs.TARGET_HANDLE_TYPE: cs.HT_LIST,
diff --git a/tests/twisted/roster/publish.py b/tests/twisted/roster/publish.py
index b78425e..45bdcd3 100644
--- a/tests/twisted/roster/publish.py
+++ b/tests/twisted/roster/publish.py
@@ -9,7 +9,7 @@ from twisted.words.xish import domish
from servicetest import (EventPattern, wrap_channel, assertLength,
assertEquals, call_async, sync_dbus)
-from hazetest import acknowledge_iq, exec_test, sync_stream
+from hazetest import acknowledge_iq, exec_test, sync_stream, close_all_groups
import constants as cs
import ns
@@ -18,6 +18,10 @@ def test(q, bus, conn, stream):
q.expect('dbus-signal', signal='StatusChanged',
args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
+ # Close all Group channels to get a clean slate, so we can rely on
+ # the NewChannels signal for the default group later
+ close_all_groups(q, bus, conn, stream)
+
call_async(q, conn.Requests, 'EnsureChannel',{
cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST,
cs.TARGET_HANDLE_TYPE: cs.HT_LIST,
diff --git a/tests/twisted/roster/subscribe.py b/tests/twisted/roster/subscribe.py
index 8c718c4..66c5a8c 100644
--- a/tests/twisted/roster/subscribe.py
+++ b/tests/twisted/roster/subscribe.py
@@ -8,7 +8,7 @@ from twisted.words.xish import domish
from servicetest import (EventPattern, wrap_channel, assertLength,
assertEquals, call_async, sync_dbus)
-from hazetest import acknowledge_iq, exec_test, sync_stream
+from hazetest import acknowledge_iq, exec_test, sync_stream, close_all_groups
import constants as cs
import ns
@@ -17,6 +17,10 @@ def test(q, bus, conn, stream):
q.expect('dbus-signal', signal='StatusChanged',
args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED])
+ # Close all Group channels to get a clean slate, so we can rely on
+ # the NewChannels signal for the default group later
+ close_all_groups(q, bus, conn, stream)
+
call_async(q, conn.Requests, 'EnsureChannel',{
cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST,
cs.TARGET_HANDLE_TYPE: cs.HT_LIST,