[telepathy-gabble/telepathy-gabble-0.8] add test for initial presence

Dafydd Harries dafydd.harries at collabora.co.uk
Wed Sep 2 16:50:23 PDT 2009


---
 tests/twisted/Makefile.am                  |    1 +
 tests/twisted/presence/initial-presence.py |   34 ++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/presence/initial-presence.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index e7eb2b5..1c7e924 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -32,6 +32,7 @@ TWISTED_TESTS = \
 	olpc/gadget-publish.py \
 	olpc/gadget-restarted.py \
 	olpc/view-presence.py \
+	presence/initial-presence.py \
 	presence/presence.py \
 	roster/ensure.py \
 	roster/groups.py \
diff --git a/tests/twisted/presence/initial-presence.py b/tests/twisted/presence/initial-presence.py
new file mode 100644
index 0000000..f0587b2
--- /dev/null
+++ b/tests/twisted/presence/initial-presence.py
@@ -0,0 +1,34 @@
+
+"""
+A simple smoke-test for C.I.SimplePresence
+
+FIXME: test C.I.Presence too
+"""
+
+from twisted.words.xish import domish
+
+from gabbletest import exec_test
+from servicetest import EventPattern, assertEquals, assertNotEquals
+import ns
+import constants as cs
+
+def test(q, bus, conn, stream):
+    props = conn.Properties.GetAll(cs.CONN_IFACE_SIMPLE_PRESENCE)
+    assertNotEquals({}, props['Statuses'])
+    conn.SimplePresence.SetPresence("away", "watching bees")
+
+    conn.Connect()
+    _, presence = q.expect_many(
+        EventPattern('dbus-signal', signal='StatusChanged',
+            args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]),
+        EventPattern('stream-presence'),
+        )
+
+    children = list(presence.stanza.elements())
+    assertEquals('show', children[0].name)
+    assertEquals('away', children[0].children[0])
+    assertEquals('status', children[1].name)
+    assertEquals('watching bees', children[1].children[0])
+
+if __name__ == '__main__':
+    exec_test(test)
-- 
1.5.6.5



More information about the telepathy-commits mailing list