[Telepathy-commits] [telepathy-haze/master] Steal presence.py test from Gabble
Will Thompson
will.thompson at collabora.co.uk
Tue Mar 24 05:21:35 PDT 2009
---
tests/twisted/Makefile.am | 1 +
tests/twisted/presence/presence.py | 57 ++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/presence/presence.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index fbca66b..dabf44e 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -1,6 +1,7 @@
TWISTED_TESTS = \
connect/success.py \
connect/fail.py \
+ presence/presence.py \
text/initiate.py
TESTS =
diff --git a/tests/twisted/presence/presence.py b/tests/twisted/presence/presence.py
new file mode 100644
index 0000000..9adf25a
--- /dev/null
+++ b/tests/twisted/presence/presence.py
@@ -0,0 +1,57 @@
+"""
+A simple smoke-test for C.I.SimplePresence
+
+FIXME: test C.I.Presence too
+"""
+
+import dbus
+
+from twisted.words.xish import domish, xpath
+
+from hazetest import exec_test
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+ 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')
+ item['jid'] = 'amy at foo.com'
+ item['subscription'] = 'both'
+
+ stream.send(event.stanza)
+
+ presence = domish.Element((None, 'presence'))
+ presence['from'] = 'amy at foo.com'
+ show = presence.addElement((None, 'show'))
+ show.addContent('away')
+ status = presence.addElement((None, 'status'))
+ status.addContent('At the pub')
+ stream.send(presence)
+
+ event = q.expect('dbus-signal', signal='PresencesChanged')
+ assert event.args[0] == { amy_handle: (3, 'away', 'At the pub') }
+
+ presence = domish.Element((None, 'presence'))
+ presence['from'] = 'amy at foo.com'
+ show = presence.addElement((None, 'show'))
+ show.addContent('chat')
+ status = presence.addElement((None, 'status'))
+ status.addContent('I may have been drinking')
+ stream.send(presence)
+
+ event = q.expect('dbus-signal', signal='PresencesChanged')
+ # FIXME: 'chat' gets lost somewhere between the XMPP stream and what Haze
+ # produces.
+ assert event.args[0] == { amy_handle: (2, 'available', 'I may have been drinking') }
+
+ conn.Disconnect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+if __name__ == '__main__':
+ exec_test(test)
+
--
1.5.6.5
More information about the telepathy-commits
mailing list