Ejemplo n.º 1
0
def test_generate_two(wordstore):
    gold = wordstore(['a', 'bb', 'ccc', 'dddd', 'eeeee'])
    with tempfile.NamedTemporaryFile('w') as f:
        f.write(gold.to_json())
        f.seek(0)

        camel = generate(f.name, 1, 1, 2, 2, 'camel')
        lower = generate(f.name, 1, 1, 2, 2, 'lower')
        upper = generate(f.name, 1, 1, 2, 2, 'upper')

    assert camel == 'Bb'
    assert lower == 'bb'
    assert upper == 'BB'
Ejemplo n.º 2
0
def test_chars(wordstore):
    gold = wordstore(['a', 'bb', 'ccc', 'dddd', 'eeeee'])
    with tempfile.NamedTemporaryFile('w') as f:
        f.write(gold.to_json())
        f.seek(0)

        passphrase = generate(f.name, 0, 6, 0, 0, 'lower')

    assert len(passphrase) > 6
Ejemplo n.º 3
0
def test_concatenation(wordstore):
    gold = wordstore(['a', 'bb', 'ccc', 'dddd', 'eeeee'])
    with tempfile.NamedTemporaryFile('w') as f:
        f.write(gold.to_json())
        f.seek(0)

        passphrase = generate(f.name, 2, 1, 3, 4, 'camel')

    assert passphrase in ['CccDddd', 'DdddCcc']
Ejemplo n.º 4
0
def main():
    args = parse_command_line()
    if args.command == 'build':
        result = build(**vars(args))
        # Handle build result.
        if args.out:
            dest = os.path.abspath(os.path.expanduser(args.out))
            with open(dest, 'w') as f:
                f.write(result)
        else:
            print(result)
    else:
        result = generate(**vars(args))
        # Handle generate result.
        print(result)