X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=tests%2Ftest_autokey.py;fp=tests%2Ftest_autokey.py;h=c57c08e3a49bb391f556e82b3d0ec9771cbf675c;hb=3350a462f460e81d96c587466f5b6a88cbba1f7e;hp=0000000000000000000000000000000000000000;hpb=14e5bc61282ef63116332c48bc9e4265fdc486c5;p=szyfrow.git diff --git a/tests/test_autokey.py b/tests/test_autokey.py new file mode 100644 index 0000000..c57c08e --- /dev/null +++ b/tests/test_autokey.py @@ -0,0 +1,34 @@ +import pytest +import string + +from szyfrow.autokey import * +from szyfrow.support.utilities import * + + +def test_encipher_message(): + enciphered = autokey_encipher('meetatthefountain', 'kilt') + expected = 'wmpmmxxaeyhbryoca' + assert enciphered == expected + +def test_decipher_message(): + deciphered = autokey_decipher('wmpmmxxaeyhbryoca', 'kilt') + expected = 'meetatthefountain' + assert deciphered == expected + +# def test_break(): +# plaintext = '''hours passed during which jerico tried every trick he +# could think of to prompt some fresh inspiration. he arranged the +# cryptograms chronologically then he arranged them by length. then +# he sorted them by frequency. he doodled on the pile of paper. he +# prowled around the hut, oblivious now to who was looking at him +# and who wasnt.''' +# # expected_key = 'samplekey' +# expected_key = 'abc' +# ciphertext = autokey_encipher(sanitise(plaintext), expected_key) +# expected_score = Ptrigrams(sanitise(plaintext)) +# actual_key, actual_score = autokey_sa_break(ciphertext, +# min_keylength=len(expected_key), max_keylength=len(expected_key), +# workers=10, max_iterations=1000, fitness=Ptrigrams +# ) +# assert expected_key == actual_key +# assert expected_score == pytest.approx(actual_score)