[Telepathy-commits] [telepathy-gabble/master] olpc/olpc-buddy-search.py: use close_view
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 07:52:22 PDT 2008
---
tests/twisted/olpc/olpc-activity-search.py | 12 +-----------
tests/twisted/olpc/olpc-buddy-search.py | 26 ++++----------------------
tests/twisted/olpc/util.py | 10 ++++++++++
3 files changed, 15 insertions(+), 33 deletions(-)
diff --git a/tests/twisted/olpc/olpc-activity-search.py b/tests/twisted/olpc/olpc-activity-search.py
index a5aca4f..1fa9888 100644
--- a/tests/twisted/olpc/olpc-activity-search.py
+++ b/tests/twisted/olpc/olpc-activity-search.py
@@ -11,7 +11,7 @@ from twisted.words.xish import domish, xpath
from twisted.words.protocols.jabber.client import IQ
from util import (announce_gadget, request_random_activity_view,
answer_error_to_pubsub_request, send_reply_to_activity_view_request,
- parse_properties, properties_to_xml, create_gadget_message)
+ parse_properties, properties_to_xml, create_gadget_message, close_view)
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -34,16 +34,6 @@ def check_view(view, conn, activities, buddies):
handles = view.GetBuddies()
assert sorted(conn.InspectHandles(1, handles)) == sorted(buddies)
-def close_view(q, view_iface, id):
- call_async(q, view_iface, 'Close')
- event, _, _ = q.expect_many(
- EventPattern('stream-message', to='gadget.localhost'),
- EventPattern('dbus-signal', signal='Closed'),
- EventPattern('dbus-return', method='Close'))
- close = xpath.queryForNodes('/message/close', event.stanza)
- assert len(close) == 1
- assert close[0]['id'] == id
-
def test(q, bus, conn, stream):
conn.Connect()
diff --git a/tests/twisted/olpc/olpc-buddy-search.py b/tests/twisted/olpc/olpc-buddy-search.py
index 91ece56..fbee3ee 100644
--- a/tests/twisted/olpc/olpc-buddy-search.py
+++ b/tests/twisted/olpc/olpc-buddy-search.py
@@ -11,7 +11,7 @@ from twisted.words.xish import domish, xpath
from twisted.words.protocols.jabber.client import IQ
from util import (announce_gadget, properties_to_xml, parse_properties,
- create_gadget_message)
+ create_gadget_message, close_view)
NS_OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties"
NS_OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities"
@@ -286,31 +286,13 @@ def test(q, bus, conn, stream):
'tom at localhost']
# close view 0
- call_async(q, view0_iface, 'Close')
- event, _ = q.expect_many(
- EventPattern('stream-message', to='gadget.localhost'),
- EventPattern('dbus-return', method='Close'))
- close = xpath.queryForNodes('/message/close', event.stanza)
- assert len(close) == 1
- assert close[0]['id'] == '0'
+ close_view(q, view0_iface, '0')
# close view 1
- call_async(q, view1_iface, 'Close')
- event, _ = q.expect_many(
- EventPattern('stream-message', to='gadget.localhost'),
- EventPattern('dbus-return', method='Close'))
- close = xpath.queryForNodes('/message/close', event.stanza)
- assert len(close) == 1
- assert close[0]['id'] == '1'
+ close_view(q, view1_iface, '1')
# close view 2
- call_async(q, view2_iface, 'Close')
- event, _ = q.expect_many(
- EventPattern('stream-message', to='gadget.localhost'),
- EventPattern('dbus-return', method='Close'))
- close = xpath.queryForNodes('/message/close', event.stanza)
- assert len(close) == 1
- assert close[0]['id'] == '2'
+ close_view(q, view2_iface, '2')
if __name__ == '__main__':
exec_test(test)
diff --git a/tests/twisted/olpc/util.py b/tests/twisted/olpc/util.py
index bf0996b..2fcffd9 100644
--- a/tests/twisted/olpc/util.py
+++ b/tests/twisted/olpc/util.py
@@ -203,6 +203,16 @@ def request_random_activity_view(q, stream, conn, max, id, activities):
return return_event.value[0]
+def close_view(q, view_iface, id):
+ call_async(q, view_iface, 'Close')
+ event, _, _ = q.expect_many(
+ EventPattern('stream-message', to='gadget.localhost'),
+ EventPattern('dbus-signal', signal='Closed'),
+ EventPattern('dbus-return', method='Close'))
+ close = xpath.queryForNodes('/message/close', event.stanza)
+ assert len(close) == 1
+ assert close[0]['id'] == id
+
# copied from Gadget
def xpath_query(query, elem):
nodes = xpath.queryForNodes(query, elem)
--
1.5.6.5
More information about the Telepathy-commits
mailing list