test hash computation in caps test
This commit is contained in:
parent
8f89d24407
commit
b5753fec60
1 changed files with 23 additions and 11 deletions
|
@ -6,6 +6,7 @@ lib.setup_env()
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common import xmpp
|
from common import xmpp
|
||||||
|
from common import helpers
|
||||||
|
|
||||||
from common.caps import CapsCache
|
from common.caps import CapsCache
|
||||||
|
|
||||||
|
@ -20,22 +21,27 @@ class TestCapsCache(unittest.TestCase):
|
||||||
self.logger = MockLogger()
|
self.logger = MockLogger()
|
||||||
self.cc = CapsCache(self.logger)
|
self.cc = CapsCache(self.logger)
|
||||||
|
|
||||||
|
self.caps_method = 'sha-1'
|
||||||
|
self.caps_hash = 'zaQfb22o0UCwYDIk8KZOnoZTnrs='
|
||||||
|
self.caps = (self.caps_method, self.caps_hash)
|
||||||
|
self.identity = {'category': 'client', 'type': 'pc'}
|
||||||
|
|
||||||
|
self.muc = 'http://jabber.org/protocol/muc'
|
||||||
|
self.chatstates = 'http://jabber.org/protocol/chatstates'
|
||||||
|
|
||||||
|
self.identities = [self.identity]
|
||||||
|
self.features = [self.muc]
|
||||||
|
|
||||||
def test_examples(self):
|
def test_examples(self):
|
||||||
'''tests the examples given in common/caps.py'''
|
'''tests the examples given in common/caps.py'''
|
||||||
|
|
||||||
caps = ('sha-1', '66/0NaeaBKkwk85efJTGmU47vXI=')
|
self.cc[self.caps].identities = self.identities
|
||||||
identity = {'category': 'client', 'type': 'pc'}
|
self.cc[self.caps].features = self.features
|
||||||
|
|
||||||
muc = 'http://jabber.org/protocol/muc'
|
self.assert_(self.muc in self.cc[self.caps].features)
|
||||||
chatstates = 'http://jabber.org/protocol/chatstates'
|
self.assert_(self.chatstates not in self.cc[self.caps].features)
|
||||||
|
|
||||||
self.cc[caps].identities = [identity]
|
id = self.cc[self.caps].identities
|
||||||
self.cc[caps].features = [muc]
|
|
||||||
|
|
||||||
self.assert_(muc in self.cc[caps].features)
|
|
||||||
self.assert_(chatstates not in self.cc[caps].features)
|
|
||||||
|
|
||||||
id = self.cc[caps].identities
|
|
||||||
|
|
||||||
self.assertEqual(1, len(id))
|
self.assertEqual(1, len(id))
|
||||||
|
|
||||||
|
@ -43,6 +49,12 @@ class TestCapsCache(unittest.TestCase):
|
||||||
self.assertEqual('client', id['category'])
|
self.assertEqual('client', id['category'])
|
||||||
self.assertEqual('pc', id['type'])
|
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__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue