[Telepathy-commits] [telepathy-salut/master] test-caps-self.py: generate caps instead of hardcoding them as they depend on the Salut version
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Thu Feb 26 11:20:19 PST 2009
---
tests/twisted/avahi/test-caps-self.py | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/tests/twisted/avahi/test-caps-self.py b/tests/twisted/avahi/test-caps-self.py
index 4e0473d..e5667be 100644
--- a/tests/twisted/avahi/test-caps-self.py
+++ b/tests/twisted/avahi/test-caps-self.py
@@ -11,11 +11,14 @@ import avahi
from xmppstream import setup_stream_listener, connect_to_stream
from servicetest import make_channel_proxy
+from config import PACKAGE_STRING
from twisted.words.xish import xpath, domish
import time
import dbus
+import hashlib
+import base64
HT_CONTACT = 1
caps_iface = 'org.freedesktop.Telepathy.' + \
@@ -41,6 +44,20 @@ def check_caps(txt, ver=None):
v = txt_get_key(txt, "ver")
assert v == ver, (v, ver)
+def compute_caps_hash(identities, features, dataforms):
+ S = ''
+
+ for identity in sorted(identities):
+ S += '%s<' % identity
+
+ for feature in sorted(features):
+ S += '%s<' % feature
+
+ # FIXME: support dataforms
+
+ m = hashlib.sha1()
+ m.update(S)
+ return base64.b64encode(m.digest())
def test(q, bus, conn):
conn.Connect()
@@ -64,7 +81,13 @@ def test(q, bus, conn):
conn_caps_iface.SetSelfCapabilities([])
e = q.expect('service-resolved', service = service)
- check_caps(e.txt, ver='6xL70ary1kvkYI5+Ilthr8ox28Y=')
+
+ caps = compute_caps_hash(['client/pc//%s' % PACKAGE_STRING], [], [])
+ check_caps(e.txt, ver=caps)
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='
exec_test(test)
--
1.5.6.5
More information about the telepathy-commits
mailing list