[telepathy-gabble/master] Test asking the server for available search keys
Will Thompson
will.thompson at collabora.co.uk
Wed Aug 26 09:21:52 PDT 2009
---
tests/twisted/constants.py | 3 +++
tests/twisted/search/unextended.py | 34 ++++++++++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index 3bfd702..adba6b2 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -70,6 +70,7 @@ CONNECTION_REFUSED = ERROR + '.ConnectionRefused'
CONNECTION_FAILED = ERROR + '.ConnectionFailed'
CONNECTION_LOST = ERROR + '.ConnectionLost'
CANCELLED = ERROR + '.Cancelled'
+DISCONNECTED = ERROR + '.Disconnected'
TUBE_PARAMETERS = CHANNEL_IFACE_TUBE + '.Parameters'
TUBE_STATE = CHANNEL_IFACE_TUBE + '.State'
@@ -78,7 +79,9 @@ DBUS_TUBE_SERVICE_NAME = CHANNEL_TYPE_DBUS_TUBE + '.ServiceName'
DBUS_TUBE_DBUS_NAMES = CHANNEL_TYPE_DBUS_TUBE + '.DBusNames'
DBUS_TUBE_SUPPORTED_ACCESS_CONTROLS = CHANNEL_TYPE_DBUS_TUBE + '.SupportedAccessControls'
+CONTACT_SEARCH_ASK = CHANNEL_TYPE_CONTACT_SEARCH + '.AvailableSearchKeys'
CONTACT_SEARCH_SERVER = CHANNEL_TYPE_CONTACT_SEARCH + '.Server'
+CONTACT_SEARCH_STATE = CHANNEL_TYPE_CONTACT_SEARCH + '.SearchState'
TUBE_CHANNEL_STATE_LOCAL_PENDING = 0
TUBE_CHANNEL_STATE_REMOTE_PENDING = 1
diff --git a/tests/twisted/search/unextended.py b/tests/twisted/search/unextended.py
index 7198e8c..33e49fc 100644
--- a/tests/twisted/search/unextended.py
+++ b/tests/twisted/search/unextended.py
@@ -5,10 +5,15 @@ extensibility via Data Forms
import dbus
+from twisted.words.protocols.jabber.client import IQ
+
from gabbletest import exec_test
-from servicetest import call_async, unwrap
+from servicetest import call_async, unwrap, make_channel_proxy, EventPattern
+
+from pprint import pformat
import constants as cs
+import ns
server = 'jud.localhost'
@@ -24,12 +29,37 @@ def test(q, bus, conn, stream):
}, signature='sv')
call_async(q, requests, 'CreateChannel', request)
- # Gabble should disco the server here.
+ iq_event = q.expect('stream-iq', to=server, query_ns=ns.SEARCH)
+ iq = iq_event.stanza
+
+ result = IQ(stream, "result")
+ result["id"] = iq["id"]
+ query = result.addElement((ns.SEARCH, 'query'))
+ query.addElement("instructions", content="cybar?")
+ for f in ["first", "last", "nick", "email"]:
+ query.addElement(f)
+ stream.send(result)
ret = q.expect('dbus-return', method='CreateChannel')
sig = q.expect('dbus-signal', signal='NewChannels')
path, props = ret.value
+ props = unwrap(props)
+
+ expected_search_keys = ['email', 'nickname', 'x-n-family', 'x-n-given']
+
+ assert props[cs.CONTACT_SEARCH_SERVER] == server, pformat(props)
+ assert sorted(props[cs.CONTACT_SEARCH_ASK]) == expected_search_keys, \
+ pformat(props)
+ assert cs.CONTACT_SEARCH_STATE not in props, pformat(props)
+
+ c = make_channel_proxy(conn, path, 'Channel')
+ c.Close()
+
+ q.expect_many(
+ EventPattern('dbus-signal', signal='Closed'),
+ EventPattern('dbus-signal', signal='ChannelClosed'),
+ )
conn.Disconnect()
q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
--
1.5.6.5
More information about the telepathy-commits
mailing list