[Telepathy-commits] [telepathy-gabble/master] add MUC utility functions to gabbletest.py
Dafydd Harries
daf at rhydd.org
Tue Oct 28 06:47:43 PDT 2008
---
tests/twisted/gabbletest.py | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/tests/twisted/gabbletest.py b/tests/twisted/gabbletest.py
index 07398fb..4d727f8 100644
--- a/tests/twisted/gabbletest.py
+++ b/tests/twisted/gabbletest.py
@@ -9,6 +9,7 @@ import sha
import sys
import time
+import ns
import servicetest
import twisted
from twisted.words.xish import domish, xpath
@@ -34,6 +35,26 @@ def make_result_iq(stream, iq):
def acknowledge_iq(stream, iq):
stream.send(make_result_iq(stream, iq))
+def request_muc_handle(q, conn, stream, muc_jid):
+ servicetest.call_async(q, conn, 'RequestHandles', 2, [muc_jid])
+ host = muc_jid.split('@')[1]
+ event = q.expect('stream-iq', to=host, query_ns=ns.DISCO_INFO)
+ result = make_result_iq(stream, event.stanza)
+ feature = result.firstChildElement().addElement('feature')
+ feature['var'] = ns.MUC
+ stream.send(result)
+ event = q.expect('dbus-return', method='RequestHandles')
+ return event.value[0][0]
+
+def make_muc_presence(affiliation, role, muc_jid, alias):
+ presence = domish.Element((None, 'presence'))
+ presence['from'] = '%s/%s' % (muc_jid, alias)
+ x = presence.addElement((ns.MUC_USER, 'x'))
+ item = x.addElement('item')
+ item['affiliation'] = affiliation
+ item['role'] = role
+ return presence
+
def sync_stream(q, stream):
"""Used to ensure that Gabble has processed all stanzas sent to it."""
--
1.5.6.5
More information about the Telepathy-commits
mailing list