[telepathy-gabble/master] Tidy some assertions in caps_helper.py
Will Thompson
will.thompson at collabora.co.uk
Tue Dec 8 03:33:13 PST 2009
These triggered while I was experimenting with different places to put
the test name, and I thought I'd fix them up.
---
tests/twisted/caps_helper.py | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/tests/twisted/caps_helper.py b/tests/twisted/caps_helper.py
index 0626e59..06ec941 100644
--- a/tests/twisted/caps_helper.py
+++ b/tests/twisted/caps_helper.py
@@ -5,8 +5,10 @@ import dbus
from twisted.words.xish import domish, xpath
from gabbletest import make_result_iq, make_presence
-from servicetest import EventPattern, assertEquals, assertContains, \
- assertDoesNotContain
+from servicetest import (
+ EventPattern,
+ assertEquals, assertContains, assertDoesNotContain, assertLength,
+ )
from config import PACKAGE_STRING
import ns
@@ -181,7 +183,7 @@ def receive_presence_and_ask_caps(q, stream, expect_dbus=True):
EventPattern('stream-presence'),
EventPattern('dbus-signal', signal='ContactCapabilitiesChanged')
)
- assert len(event_dbus.args) == 1
+ assertLength(1, event_dbus.args)
signaled_caps = event_dbus.args[0]
else:
presence = q.expect('stream-presence')
@@ -192,11 +194,11 @@ def receive_presence_and_ask_caps(q, stream, expect_dbus=True):
def disco_caps(q, stream, presence):
c_nodes = xpath.queryForNodes('/presence/c', presence.stanza)
assert c_nodes is not None
- assert len(c_nodes) == 1
+ assertLength(1, c_nodes)
hash = c_nodes[0].attributes['hash']
ver = c_nodes[0].attributes['ver']
node = c_nodes[0].attributes['node']
- assert hash == 'sha-1'
+ assertEquals('sha-1', hash)
# ask caps
request = """
@@ -218,7 +220,8 @@ def disco_caps(q, stream, presence):
features.append(feature['var'])
# Check if the hash matches the announced capabilities
- assert ver == compute_caps_hash(['client/pc//%s' % PACKAGE_STRING], features, {})
+ assertEquals(compute_caps_hash(['client/pc//%s' % PACKAGE_STRING], features, {}),
+ ver)
return (event, features)
@@ -282,11 +285,13 @@ def send_disco_reply(stream, stanza, features, dataforms={}):
if __name__ == '__main__':
# example from XEP-0115
- assert compute_caps_hash(['client/pc//Exodus 0.9.1'],
- ["http://jabber.org/protocol/disco#info",
- "http://jabber.org/protocol/disco#items",
- "http://jabber.org/protocol/muc", "http://jabber.org/protocol/caps"],
- {}) == 'QgayPKawpkPSDYmwT/WM94uAlu0='
+ assertEquals('QgayPKawpkPSDYmwT/WM94uAlu0=',
+ compute_caps_hash(['client/pc//Exodus 0.9.1'],
+ ["http://jabber.org/protocol/disco#info",
+ "http://jabber.org/protocol/disco#items",
+ "http://jabber.org/protocol/muc",
+ "http://jabber.org/protocol/caps"],
+ {}))
# another example from XEP-0115
identities = [u'client/pc/en/Psi 0.11', u'client/pc/el/Ψ 0.11']
--
1.5.6.5
More information about the telepathy-commits
mailing list