[telepathy-haze/master] Tests: Respond to roster gets with the empty roster
Will Thompson
will.thompson at collabora.co.uk
Tue Aug 25 08:17:31 PDT 2009
Recent versions of prpl-jabber wait for a reply to its initial roster
pull before declaring the connection to be online. So, let's just answer
with the empty roster for now.
---
tests/twisted/hazetest.py | 9 +++++++++
tests/twisted/presence/presence.py | 12 +++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/tests/twisted/hazetest.py b/tests/twisted/hazetest.py
index e1a817b..dba64d9 100644
--- a/tests/twisted/hazetest.py
+++ b/tests/twisted/hazetest.py
@@ -240,6 +240,9 @@ class BaseXmlStream(xmlstream.XmlStream):
self.addObserver(
"/iq/query[@xmlns='http://jabber.org/protocol/disco#info']",
self._cb_disco_iq)
+ self.addObserver(
+ "/iq/query[@xmlns='jabber:iq:roster']",
+ self._cb_roster_get)
self.event_func(servicetest.Event('stream-authenticated'))
def _cb_disco_iq(self, iq):
@@ -256,6 +259,12 @@ class BaseXmlStream(xmlstream.XmlStream):
iq['type'] = 'result'
self.send(iq)
+ def _cb_roster_get(self, iq):
+ # Just send back an empty roster. prpl-jabber waits for the roster
+ # before saying it's online.
+ if iq.getAttribute('type') == 'get':
+ self.send(make_result_iq(self, iq))
+
class JabberXmlStream(BaseXmlStream):
version = (0, 9)
diff --git a/tests/twisted/presence/presence.py b/tests/twisted/presence/presence.py
index 9adf25a..dea36a3 100644
--- a/tests/twisted/presence/presence.py
+++ b/tests/twisted/presence/presence.py
@@ -7,6 +7,7 @@ FIXME: test C.I.Presence too
import dbus
from twisted.words.xish import domish, xpath
+from twisted.words.protocols.jabber.client import IQ
from hazetest import exec_test
@@ -16,14 +17,15 @@ def test(q, bus, conn, stream):
amy_handle = conn.RequestHandles(1, ['amy at foo.com'])[0]
- event = q.expect('stream-iq', query_ns='jabber:iq:roster')
- event.stanza['type'] = 'result'
-
- item = event.query.addElement('item')
+ # Divergence from Gabble: hazetest responds to all roster gets with an
+ # empty roster, so we need to push the roster.
+ iq = IQ(stream, 'set')
+ query = iq.addElement(('jabber:iq:roster', 'query'))
+ item = query.addElement('item')
item['jid'] = 'amy at foo.com'
item['subscription'] = 'both'
- stream.send(event.stanza)
+ stream.send(iq)
presence = domish.Element((None, 'presence'))
presence['from'] = 'amy at foo.com'
--
1.5.6.5
More information about the telepathy-commits
mailing list