[telepathy-gabble/master] Test that the fix for fd.o#25341 works.

Will Thompson will.thompson at collabora.co.uk
Mon Dec 14 09:55:40 PST 2009


---
 tests/twisted/Makefile.am            |    1 +
 tests/twisted/vcard/redundant-set.py |   47 ++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/vcard/redundant-set.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 8f8ab96..1c7acaf 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -83,6 +83,7 @@ TWISTED_TESTS = \
 	tubes/test-get-available-tubes.py \
 	tubes/test-socks5-muc.py \
 	vcard/overlapping-sets.py \
+	vcard/redundant-set.py \
 	vcard/set-set-disconnect.py \
 	vcard/test-alias-empty-vcard.py \
 	vcard/test-alias-pep.py \
diff --git a/tests/twisted/vcard/redundant-set.py b/tests/twisted/vcard/redundant-set.py
new file mode 100644
index 0000000..05a73f1
--- /dev/null
+++ b/tests/twisted/vcard/redundant-set.py
@@ -0,0 +1,47 @@
+"""
+Regression test for <http://bugs.freedesktop.org/show_bug.cgi?id=25341>, where
+Gabble redundantly re-set the user's own vCard even if nothing had changed.
+"""
+
+from servicetest import EventPattern, sync_dbus
+from gabbletest import exec_test, make_result_iq, sync_stream, GoogleXmlStream
+import constants as cs
+
+def not_google(q, bus, conn, stream):
+    test(q, bus, conn, stream, False)
+
+def google(q, bus, conn, stream):
+    test(q, bus, conn, stream, True)
+
+def test(q, bus, conn, stream, is_google):
+    conn.Connect()
+    _, iq_event = q.expect_many(
+        EventPattern('dbus-signal', signal='StatusChanged',
+            args=[cs.CONN_STATUS_CONNECTED, cs.CSR_REQUESTED]),
+        EventPattern('stream-iq', to=None, query_ns='vcard-temp',
+            query_name='vCard'))
+
+    result = make_result_iq(stream, iq_event.stanza)
+
+    # Testing reveals that Google's vCard server does not actually support
+    # NICKNAME (or indeed any fields beside FN and PHOTO): if you set a vCard
+    # including it, it accepts the request but strips out the unsupported
+    # fields. So if the server looks like Google, we don't bother re-setting
+    # the NICKNAME.
+    if not is_google:
+        vcard = result.firstChildElement()
+        vcard.addElement('NICKNAME', content='oh hello there')
+
+    stream.send(result)
+
+    q.forbid_events([
+        EventPattern('stream-iq', iq_type='set', query_ns='vcard-temp',
+            query_name='vCard')
+        ])
+    sync_stream(q, stream)
+    sync_dbus(bus, q, conn)
+
+if __name__ == '__main__':
+    exec_test(not_google, params={ 'alias': 'oh hello there' })
+    exec_test(google, params={ 'alias': 'oh hello there' },
+        protocol=GoogleXmlStream)
-- 
1.5.6.5




More information about the telepathy-commits mailing list