<commit_before># file: scripts-tests.py
# vim:fileencoding=utf-8:ft=python
#
# Author: <NAME> <<EMAIL>>
# Created: 2015-04-06 13:08:02 +0200
# Last modified: 2016-06-10 20:49:02 +0200

"""
Tests for functions in python files in the scripts directory.

To run the tests use: py.test -v scripts-tests.py
"""

from genpw import roundup, genpw
from nospaces import fixname


def test_roundup():
    assert roundup(1) == 3
    assert roundup(2) == 3
    assert roundup(3) == 3
    assert roundup(4) == 3
    assert roundup(5) == 6
    assert roundup(6) == 6
    assert roundup(7) == 6
    assert roundup(8) == 6
    assert roundup(9) == 9


def test_genpw():
    assert len(genpw(1)) == 4
    assert len(genpw(2)) == 4
    assert len(genpw(3)) == 4
    assert len(genpw(4)) == 4
    assert len(genpw(5)) == 8
    assert len(genpw(8)) == 8
    assert len(genpw(12)) == 12


def test_fixname():
    rv = fixname('dit is  een\ttest')
    assert rv == 'dit_is_een_test'<commit_msg>Add extra tests.<commit_after># file: scripts-tests.py
# vim:fileencoding=utf-8:ft=python
#
# Author: <NAME> <<EMAIL>>
# Created: 2015-04-06 13:08:02 +0200
# Last modified: 2016-06-11 00:30:24 +0200

"""
Tests for functions in python files in the scripts directory.

To run the tests use: py.test -v scripts-tests.py
"""

from collections import Counter

from genotp import rndcaps, otp
from genpw import roundup, genpw
from nospaces import fixname
from offsetsrt import str2ms, ms2str


def test_rndcaps():
    rv = rndcaps(20)
    assert len(rv) == 20
    assert all(j in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' for j in rv)
    v = Counter(rndcaps(100000)).values()
    mxc = max(v)
    mnc = min(v)
    assert mxc/mnc < 1.3


def test_otp():
    lines = otp(5).splitlines()
    assert len(lines) == 5
    for ln in lines:
        assert len(ln) == 75


def test_roundup():
    assert roundup(1) == 3
    assert roundup(2) == 3
    assert roundup(3) == 3
    assert roundup(4) == 3
    assert roundup(5) == 6
    assert roundup(6) == 6
    assert roundup(7) == 6
    assert roundup(8) == 6
    assert roundup(9) == 9


def test_genpw():
    assert len(genpw(1)) == 4
    assert len(genpw(2)) == 4
    assert len(genpw(3)) == 4
    assert len(genpw(4)) == 4
    assert len(genpw(5)) == 8
    assert len(genpw(8)) == 8
    assert len(genpw(12)) == 12


def test_fixname():
    rv = fixname('dit is  een\ttest')
    assert rv == 'dit_is_een_test'


def test_srt():
    for j in range(7200):
        p = j*10
        ts = ms2str(p)
        k = str2ms(ts)
        assert p == k
{'fraction_non_alphanumeric': 0.14195583596214512, 'fraction_numerical': 0.06624605678233439, 'mean_word_length': 3.0592, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '868066', 'n_tokens_mistral': 1062, 'n_tokens_neox': 944, 'n_words': 276}