Back to index

moin  1.9.0~rc2
Functions
test_capat Namespace Reference

Functions

def test_ver_simple
def test_ver_complex
def test_xml

Function Documentation

Definition at line 20 of file test_capat.py.

00020 
00021 def test_ver_complex():
00022     # this test should verify that ordering works properly
00023     ident = (("client", "animal"),
00024              ("client", "bear"), # type ordering after category ordering
00025              ("apples", "bar"),
00026              ("apple", "foo"), # "apples" starts with "apple"
00027                                # thus it's greater
00028             )
00029     feat = ()
00030 
00031     expected = capat.hash_new('sha1')
00032     expected.update("apple/foo<apples/bar<client/animal<client/bear<")
00033     expected = capat.base64.b64encode(expected.digest())
00034     assert capat.generate_ver(ident, feat) == expected

Definition at line 10 of file test_capat.py.

00010 
00011 def test_ver_simple():
00012     # example values supplied by the XEP
00013     ident = (("client", "pc"), )
00014     feat = ("http://jabber.org/protocol/disco#info",
00015             "http://jabber.org/protocol/disco#items",
00016             "http://jabber.org/protocol/muc",
00017            )
00018 
00019     assert capat.generate_ver(ident, feat) == "8RovUdtOmiAjzj+xI7SK5BCw3A8="

Definition at line 35 of file test_capat.py.

00035 
00036 def test_xml():
00037     try:
00038         import pyxmpp.iq
00039     except ImportError:
00040         py.test.skip("pyxmpp needs to be installed for this test")
00041 
00042     x = pyxmpp.iq.Iq(stanza_type='result', stanza_id='disco1',
00043                      from_jid='romeo@montague.lit/orchard',
00044                      to_jid='juliet@capulet.lit/chamber')
00045     y = x.new_query(ns_uri='http://jabber.org/protocol/disco#info')
00046     z = y.newChild(None, 'identity', None)
00047     z.setProp('category', 'client')
00048     z.setProp('type', 'pc')
00049     y.newChild(None, 'feature', None).setProp(
00050         'var', 'http://jabber.org/protocol/disco#info')
00051     y.newChild(None, 'feature', None).setProp(
00052         'var', 'http://jabber.org/protocol/disco#items')
00053     y.newChild(None, 'feature', None).setProp(
00054         'var', 'http://jabber.org/protocol/muc')
00055 
00056     assert capat.hash_iq(x) == "8RovUdtOmiAjzj+xI7SK5BCw3A8="
00057     # hash value taken from `test_ver_simple`
00058