view jabberbot/_tests/ @ 3748:dc917a577d38

add multiconfig.DefaultExpression for documentation this allows showing the actual expression used as the default rather than using '%r', use sparingly
author Johannes Berg <johannes AT sipsolutions DOT net>
date Sun, 22 Jun 2008 00:36:25 +0200
parents 313a1d430bcb
line wrap: on
line source
# -*- coding: utf-8 -*-

import py

    from jabberbot import capat
except ImportError:
    py.test.skip("Skipping jabber bot tests - pyxmpp is not installed")

def test_ver_simple():
    # example values supplied by the XEP
    ident = (("client", "pc"), )
    feat = ("",

    assert capat.generate_ver(ident, feat) == "8RovUdtOmiAjzj+xI7SK5BCw3A8="

def test_ver_complex():
    # this test should verify that ordering works properly
    ident = (("client", "animal"),
             ("client", "bear"), # type ordering after category ordering
             ("apples", "bar"),
             ("apple", "foo"), # "apples" starts with "apple"
                               # thus it's greater
    feat = ()

    expected = capat.hash_new('sha1')
    expected = capat.base64.b64encode(expected.digest())
    assert capat.generate_ver(ident, feat) == expected

def test_xml():
    except ImportError:
        py.test.skip("pyxmpp needs to be installed for this test")

    x ='result', stanza_id='disco1',
    y = x.new_query(ns_uri='')
    z = y.newChild(None, 'identity', None)
    z.setProp('category', 'client')
    z.setProp('type', 'pc')
    y.newChild(None, 'feature', None).setProp(
        'var', '')
    y.newChild(None, 'feature', None).setProp(
        'var', '')
    y.newChild(None, 'feature', None).setProp(
        'var', '')

    assert capat.hash_iq(x) == "8RovUdtOmiAjzj+xI7SK5BCw3A8="
    # hash value taken from `test_ver_simple`