telepathy-gabble: Test ClearAvatar()

Will Thompson wjt at kemper.freedesktop.org
Thu Dec 6 09:37:23 PST 2012


Module: telepathy-gabble
Branch: master
Commit: de157563532a3196dc55a14ee9e3887a4529ec4b
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=de157563532a3196dc55a14ee9e3887a4529ec4b

Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Mon Nov 26 16:58:48 2012 +0000

Test ClearAvatar()

I wasn't sure from reading the code that this actually worked any more,
and it wasn't tested. I'm happy to say that it does work.

---

 tests/twisted/Makefile.am           |    1 +
 tests/twisted/vcard/clear-avatar.py |   27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index e59e858..8e88892 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -144,6 +144,7 @@ TWISTED_TUBE_TESTS = \
 	$(NULL)
 
 TWISTED_VCARD_TESTS = \
+	vcard/clear-avatar.py \
 	vcard/disconnect-during-pep.py \
 	vcard/get-contact-info.py \
 	vcard/item-not-found.py \
diff --git a/tests/twisted/vcard/clear-avatar.py b/tests/twisted/vcard/clear-avatar.py
new file mode 100644
index 0000000..333c5e8
--- /dev/null
+++ b/tests/twisted/vcard/clear-avatar.py
@@ -0,0 +1,27 @@
+"""
+Tests the very simple case of "clearing your own avatar".
+"""
+
+from servicetest import call_async
+from gabbletest import (
+    exec_test, expect_and_handle_get_vcard, expect_and_handle_set_vcard, current_vcard
+    )
+
+def test(q, bus, conn, stream):
+    photo = current_vcard.addElement((None, 'PHOTO'))
+    photo.addElement((None, 'TYPE')).addContent('image/fake')
+    photo.addElement((None, 'BINVAL')).addContent('NYANYANYANYANYAN')
+
+    call_async(q, conn.Avatars, 'ClearAvatar')
+
+    expect_and_handle_get_vcard(q, stream)
+
+    def check(vcard):
+        assert len(vcard.children) == 0, vcard.toXml()
+
+    expect_and_handle_set_vcard(q, stream, check=check)
+
+    q.expect('dbus-return', method='ClearAvatar')
+
+if __name__ == '__main__':
+    exec_test(test)



More information about the telepathy-commits mailing list