kumisbespassung/fh_passphrase/fh_passphrase_test.py

32 lines
673 B
Python

from fh_passphrase import PasswordMaker
from pytest import raises
def split_password(password):
letters = []
special = []
for i in range(len(password)):
if not i % 2:
letters += password[i]
else:
special += password[i]
return letters, special
def test_passwordmaker():
maker = PasswordMaker()
with raises(ValueError):
maker.generate_password("Short sentence.")
sentence = "This is a longer sentence."
password = maker.generate_password(sentence)
letters, special = split_password(password)
assert letters == [word[0] for word in sentence.split()]
assert len(special) == len(letters) - 1
for char in special:
assert char in maker.special