view MoinMoin/util/_tests/test_util.py @ 174:e8f61cbd661b

modularize crypto/random stuff, move it to MoinMoin.util.crypto, pw change bugfix on password change, the new password was not saved to the profile User / crypto code: minor optimizations / refactorings crypto module contents: password hashing/encryption, validation, pw hash upgrades: * pw_hash = crypt_password(password) * is_valid = valid_password(password, pw_hash) * upgraded_pw_hash = upgrade_password(password, pw_hash) password recovery: * key, token = generate_token() * is_valid = valid_token(key, token) random strings: * rs = random_string(length, chars) compute ascii cache keys: * key = cache_key(**kw)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 07 Apr 2011 20:56:35 +0200
parents 4cd8edde9e94
children 57af51410c3a
line wrap: on
line source
# Copyright: 2007 MoinMoin:ThomasWaldmann
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
    MoinMoin - MoinMoin.util Tests
"""


from MoinMoin import util

class TestUtil:

    def testRangeList(self):
        """ util.rangelist: test correct function for misc. input values """
        result = util.rangelist([])
        expected = ''
        assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()

        result = util.rangelist([42])
        expected = '42'
        assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()

        result = util.rangelist([42, 23])
        expected = '23,42'
        assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()

        result = util.rangelist([1, 2, 3, 4, 5])
        expected = '1-5'
        assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()

        result = util.rangelist([2, 5, 3])
        expected = '2-3,5'
        assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()

        result = util.rangelist([2, 3, 5, 6])
        expected = '2-3,5-6'
        assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()

        result = util.rangelist([2, 3, 5, 6, 23, 100, 101, 102, 104])
        expected = '2-3,5-6,23,100-102,104'
        assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()


coverage_modules = ['MoinMoin.util']