Skip to content
Snippets Groups Projects
Commit b5753fec authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

test hash computation in caps test

parent 8f89d244
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ lib.setup_env()
from common import gajim
from common import xmpp
from common import helpers
from common.caps import CapsCache
......@@ -20,22 +21,27 @@ class TestCapsCache(unittest.TestCase):
self.logger = MockLogger()
self.cc = CapsCache(self.logger)
def test_examples(self):
'''tests the examples given in common/caps.py'''
self.caps_method = 'sha-1'
self.caps_hash = 'zaQfb22o0UCwYDIk8KZOnoZTnrs='
self.caps = (self.caps_method, self.caps_hash)
self.identity = {'category': 'client', 'type': 'pc'}
caps = ('sha-1', '66/0NaeaBKkwk85efJTGmU47vXI=')
identity = {'category': 'client', 'type': 'pc'}
self.muc = 'http://jabber.org/protocol/muc'
self.chatstates = 'http://jabber.org/protocol/chatstates'
muc = 'http://jabber.org/protocol/muc'
chatstates = 'http://jabber.org/protocol/chatstates'
self.identities = [self.identity]
self.features = [self.muc]
self.cc[caps].identities = [identity]
self.cc[caps].features = [muc]
def test_examples(self):
'''tests the examples given in common/caps.py'''
self.assert_(muc in self.cc[caps].features)
self.assert_(chatstates not in self.cc[caps].features)
self.cc[self.caps].identities = self.identities
self.cc[self.caps].features = self.features
id = self.cc[caps].identities
self.assert_(self.muc in self.cc[self.caps].features)
self.assert_(self.chatstates not in self.cc[self.caps].features)
id = self.cc[self.caps].identities
self.assertEqual(1, len(id))
......@@ -43,6 +49,12 @@ class TestCapsCache(unittest.TestCase):
self.assertEqual('client', id['category'])
self.assertEqual('pc', id['type'])
def test_hash(self):
'''tests the hash computation'''
computed_hash = helpers.compute_caps_hash(self.identities, self.features)
self.assertEqual(self.caps_hash, computed_hash)
if __name__ == '__main__':
unittest.main()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment