[Telepathy-commits] [telepathy-gabble/master] Port test-save-alias-to-vcard.py to newer test api
Will Thompson
will.thompson at collabora.co.uk
Mon Mar 16 07:38:13 PDT 2009
---
tests/twisted/ns.py | 1 +
tests/twisted/vcard/test-save-alias-to-vcard.py | 88 ++++------------------
2 files changed, 17 insertions(+), 72 deletions(-)
diff --git a/tests/twisted/ns.py b/tests/twisted/ns.py
index 143aa1c..2b2dc6d 100644
--- a/tests/twisted/ns.py
+++ b/tests/twisted/ns.py
@@ -30,4 +30,5 @@ SI = 'http://jabber.org/protocol/si'
SI_MULTIPLE = 'http://telepathy.freedesktop.org/xmpp/si-multiple'
STANZA = "urn:ietf:params:xml:ns:xmpp-stanzas"
TUBES = 'http://telepathy.freedesktop.org/xmpp/tubes'
+VCARD_TEMP = 'vcard-temp'
X_DATA = 'jabber:x:data'
diff --git a/tests/twisted/vcard/test-save-alias-to-vcard.py b/tests/twisted/vcard/test-save-alias-to-vcard.py
index 90b7df0..4ff2ee3 100644
--- a/tests/twisted/vcard/test-save-alias-to-vcard.py
+++ b/tests/twisted/vcard/test-save-alias-to-vcard.py
@@ -1,4 +1,3 @@
-
"""
Regression test.
@@ -8,83 +7,28 @@ Regression test.
parameter
"""
-from servicetest import lazy
-from gabbletest import go
-
- at lazy
-def expect_connected(event, data):
- if event.type != 'dbus-signal':
- return False
-
- if event.signal != 'StatusChanged':
- return False
-
- if event.args != [0, 1]:
- return False
-
- return True
-
-def expect_get_vcard(event, data):
- if event.type != 'stream-iq':
- return False
-
- # Looking for something like this:
- # <iq xmlns='jabber:client' type='get' id='262286393608'>
- # <vCard xmlns='vcard-temp'/>
-
- iq = event.stanza
-
- if iq['type'] != 'get':
- return False
-
- if iq.uri != 'jabber:client':
- return False
-
- vcard = list(iq.elements())[0]
-
- if vcard.name != 'vCard':
- return False
-
- # Send empty vCard back.
- iq['type'] = 'result'
- data['stream'].send(iq)
- return True
-
-def expect_set_vcard(event, data):
- if event.type != 'stream-iq':
- return False
-
- iq = event.stanza
-
- if iq['type'] != 'set':
- return False
-
- if iq.uri != 'jabber:client':
- return False
-
- vcard = list(iq.elements())[0]
+from gabbletest import exec_test, acknowledge_iq, \
+ expect_and_handle_get_vcard, expect_and_handle_set_vcard
- if vcard.name != 'vCard':
- return False
+import ns
- nickname = vcard.firstChildElement()
- assert nickname.name == 'NICKNAME'
- assert str(nickname) == 'Some Guy'
- data['conn_iface'].Disconnect()
- return True
+def test(q, bus, conn, stream):
+ conn.Connect()
-def expect_disconnected(event, data):
- if event.type != 'dbus-signal':
- return False
+ expect_and_handle_get_vcard(q, stream)
- if event.signal != 'StatusChanged':
- return False
+ def check_vcard(vcard):
+ for e in vcard.elements():
+ if e.name == 'NICKNAME':
+ assert str(e) == 'Some Guy', e.toXml()
+ return
+ assert False, vcard.toXml()
- if event.args != [2, 1]:
- return False
+ expect_and_handle_set_vcard(q, stream, check_vcard)
- return True
+ conn.Disconnect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
if __name__ == '__main__':
- go({'alias': 'Some Guy'})
+ exec_test(test, params={'alias': 'Some Guy'})
--
1.5.6.5
More information about the telepathy-commits
mailing list