telepathy-gabble: muc/chat-states: tidy up checking message bodies

Will Thompson wjt at kemper.freedesktop.org
Mon Mar 4 04:22:17 PST 2013


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

Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Fri Feb 22 08:15:30 2013 +0000

muc/chat-states: tidy up checking message bodies

---

 tests/twisted/muc/chat-states.py |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/tests/twisted/muc/chat-states.py b/tests/twisted/muc/chat-states.py
index eaa5c65..b5b3898 100644
--- a/tests/twisted/muc/chat-states.py
+++ b/tests/twisted/muc/chat-states.py
@@ -3,7 +3,7 @@ Regression test for <https://bugs.freedesktop.org/show_bug.cgi?id=32952>,
 wherein chat states in MUCs were misparsed, and MUC chat states in general.
 """
 
-from servicetest import assertEquals
+from servicetest import assertEquals, assertLength
 from gabbletest import exec_test, elem
 from mucutil import join_muc_and_check
 import ns
@@ -111,13 +111,9 @@ def test(q, bus, conn, stream):
     assertEquals(cs.CHAT_STATE_ACTIVE,
             states.get(user, cs.CHAT_STATE_INACTIVE))
 
-    def is_body(e):
-        if e.name == 'body':
-            assert e.children[0] == u'hi.', e.toXml()
-            return True
-        return False
-
-    assert len([x for x in stanza.elements() if is_body(x)]) == 1, stanza.toXml()
+    bodies = list(stanza.elements(uri=ns.CLIENT, name='body'))
+    assertLength(1, bodies)
+    assertEquals(u'hi.', bodies[0].children[0])
 
 if __name__ == '__main__':
       exec_test(test)



More information about the telepathy-commits mailing list