[telepathy-gabble/master] Test Gabble sends search terms correctly

Will Thompson will.thompson at collabora.co.uk
Wed Aug 26 09:21:50 PDT 2009


---
 tests/twisted/constants.py         |    4 ++++
 tests/twisted/search/unextended.py |   29 +++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index adba6b2..4a0f0eb 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -83,6 +83,10 @@ CONTACT_SEARCH_ASK = CHANNEL_TYPE_CONTACT_SEARCH + '.AvailableSearchKeys'
 CONTACT_SEARCH_SERVER = CHANNEL_TYPE_CONTACT_SEARCH + '.Server'
 CONTACT_SEARCH_STATE = CHANNEL_TYPE_CONTACT_SEARCH + '.SearchState'
 
+SEARCH_NOT_STARTED = 0
+SEARCH_IN_PROGRESS = 1
+SEARCH_COMPLETED = 2
+
 TUBE_CHANNEL_STATE_LOCAL_PENDING = 0
 TUBE_CHANNEL_STATE_REMOTE_PENDING = 1
 TUBE_CHANNEL_STATE_OPEN = 2
diff --git a/tests/twisted/search/unextended.py b/tests/twisted/search/unextended.py
index 33e49fc..aaa479e 100644
--- a/tests/twisted/search/unextended.py
+++ b/tests/twisted/search/unextended.py
@@ -54,6 +54,35 @@ def test(q, bus, conn, stream):
     assert cs.CONTACT_SEARCH_STATE not in props, pformat(props)
 
     c = make_channel_proxy(conn, path, 'Channel')
+    c_props = dbus.Interface(c, cs.PROPERTIES_IFACE)
+    c_search = dbus.Interface(c, cs.CHANNEL_TYPE_CONTACT_SEARCH)
+
+    state = c_props.Get(cs.CHANNEL_TYPE_CONTACT_SEARCH, 'SearchState')
+    assert state == cs.SEARCH_NOT_STARTED, state
+
+    terms = { 'x-n-family': 'Thomspon' }
+    call_async(q, c_search, 'Search', terms)
+
+    _, ssc_event, iq_event = q.expect_many(
+        EventPattern('dbus-return', method='Search'),
+        EventPattern('dbus-signal', signal='SearchStateChanged'),
+        EventPattern('stream-iq', to=server, query_ns=ns.SEARCH),
+        )
+
+    assert ssc_event.args[0] == cs.SEARCH_IN_PROGRESS
+
+    state = c_props.Get(cs.CHANNEL_TYPE_CONTACT_SEARCH, 'SearchState')
+    assert state == cs.SEARCH_IN_PROGRESS, state
+
+    iq = iq_event.stanza
+    query = iq.firstChildElement()
+    i = 0
+    for field in query.elements():
+        assert field.name == 'last', field.toXml()
+        assert field.children[0] == u'Thomspon', field.children[0]
+        i += 1
+    assert i == 1, query
+
     c.Close()
 
     q.expect_many(
-- 
1.5.6.5




More information about the telepathy-commits mailing list