Many tests done, still more to come.
[szyfrow.git] / tests / test_autokey.py
1 import pytest
2 import string
3
4 from szyfrow.autokey import *
5 from szyfrow.support.utilities import *
6
7
8 def test_encipher_message():
9 enciphered = autokey_encipher('meetatthefountain', 'kilt')
10 expected = 'wmpmmxxaeyhbryoca'
11 assert enciphered == expected
12
13 def test_decipher_message():
14 deciphered = autokey_decipher('wmpmmxxaeyhbryoca', 'kilt')
15 expected = 'meetatthefountain'
16 assert deciphered == expected
17
18 # def test_break():
19 # plaintext = '''hours passed during which jerico tried every trick he
20 # could think of to prompt some fresh inspiration. he arranged the
21 # cryptograms chronologically then he arranged them by length. then
22 # he sorted them by frequency. he doodled on the pile of paper. he
23 # prowled around the hut, oblivious now to who was looking at him
24 # and who wasnt.'''
25 # # expected_key = 'samplekey'
26 # expected_key = 'abc'
27 # ciphertext = autokey_encipher(sanitise(plaintext), expected_key)
28 # expected_score = Ptrigrams(sanitise(plaintext))
29 # actual_key, actual_score = autokey_sa_break(ciphertext,
30 # min_keylength=len(expected_key), max_keylength=len(expected_key),
31 # workers=10, max_iterations=1000, fitness=Ptrigrams
32 # )
33 # assert expected_key == actual_key
34 # assert expected_score == pytest.approx(actual_score)