Exemplo n.º 1
0
def test_decrypt_wrap_long():
    """
    Test basic decrypt text function, wrapping around 1 or more times
    """
    assert Ceasar.decrypt("npqusn", 30) == "jlmqoj"
    assert Ceasar.decrypt("pasdads", 94) == "zkcnknc"
    assert Ceasar.decrypt("PASDADS", 94) == "ZKCNKNC"
Exemplo n.º 2
0
def test_encrypt_wrap_long():
    """
    Test basic encrypt text function, wrapping around 1 or more times
    """
    assert Ceasar.encrypt("jklmnop", 30) == "nopqrst"
    assert Ceasar.encrypt("zanj", 94) == "pqdz"
    assert Ceasar.encrypt("ZANJ", 94) == "PQDZ"
Exemplo n.º 3
0
def test_encrypt():
    """
    Test basic encrypt text function, with lower and upper case characters
    """
    assert Ceasar.encrypt("abcdefghijklmn", 1) == "bcdefghijklmno"
    assert Ceasar.encrypt("jklmnop", 5) == "opqrstu"
    assert Ceasar.encrypt("xyza", 2) == "zabc"
    assert Ceasar.encrypt("XYZA", 2) == "ZABC"
Exemplo n.º 4
0
def test_decrypt():
    """
    Test basic decrypt text function, with lower and upper case characters
    """
    assert Ceasar.decrypt("bcdefghijklmno", 1) == "abcdefghijklmn"
    assert Ceasar.decrypt("opqrstu", 5) == "jklmnop"
    assert Ceasar.decrypt("zabc", 2) == "xyza"
    assert Ceasar.decrypt("ZABC", 2) == "XYZA"
Exemplo n.º 5
0
def test_encrypt_letter():
    """
    Test basic encrypt letters function with lower and upper case letters
    """
    assert Ceasar._encrypt_letter("a", 1) == "b"
    assert Ceasar._encrypt_letter("j", 5) == "o"
    assert Ceasar._encrypt_letter("x", 2) == "z"
    assert Ceasar._encrypt_letter("J", 5) == "O"
    assert Ceasar._encrypt_letter("X", 2) == "Z"
Exemplo n.º 6
0
def test_decrypt_letter():
    """
    Test basic decrypt letters function with lower and upper case letters
    """
    assert Ceasar._decrypt_letter("b", 1) == "a"
    assert Ceasar._decrypt_letter("o", 5) == "j"
    assert Ceasar._decrypt_letter("z", 2) == "x"
    assert Ceasar._decrypt_letter("O", 5) == "J"
    assert Ceasar._decrypt_letter("Z", 2) == "X"
Exemplo n.º 7
0
def test_decrypt_letter_wrap_long():
    """
    Test basic decrypt letters function, wrapping around 1 or more times
    """
    assert Ceasar._decrypt_letter("N", 30) == "J"
    assert Ceasar._decrypt_letter("p", 94) == "z"
Exemplo n.º 8
0
def test_encrypt_letter_wrap_long():
    """
    Test basic encrypt letters function, wrapping around 1 or more times
    """
    assert Ceasar._encrypt_letter("j", 30) == "n"
    assert Ceasar._encrypt_letter("Z", 94) == "P"
Exemplo n.º 9
0
def test_decrypt_letter_non_character():
    """
    Assert there is an error when trying to decrypt a non character
    """
    with pytest.raises(NotAllowedValue):
        assert Ceasar._decrypt_letter("0", 10)
Exemplo n.º 10
0
def test_decrypt_letter_wrap():
    """
    Test basic decrypt letters function, wrapping around the alphabet
    """
    assert Ceasar._decrypt_letter("A", 1) == "Z"
    assert Ceasar._decrypt_letter("e", 5) == "z"
Exemplo n.º 11
0
def test_encrypt_letter_wrap():
    """
    Test basic encrypt letters function, wrapping around the alphabet
    """
    assert Ceasar._encrypt_letter("z", 1) == "a"
    assert Ceasar._encrypt_letter("Z", 5) == "E"
Exemplo n.º 12
0
def test_decrypt_letter_no_offset():
    """
    Test basic decrypt letters function omitting `offset` parameter
    """
    assert Ceasar._decrypt_letter("r") == "r"
Exemplo n.º 13
0
def test_decrypt_caps_alternate():
    """
    Test basic decrypt text function, with upper and lower case characters in the same text
    """
    assert Ceasar.decrypt("FgHiJk", 5) == "AbCdEf"
Exemplo n.º 14
0
def test_decrypt_non_character():
    """
    Assert there is an error when trying to decrypt a text with a non character
    """
    with pytest.raises(NotAllowedValue):
        assert Ceasar.decrypt("abcdefh0", 10)
Exemplo n.º 15
0
def test_decrypt_no_offset():
    """
    Test basic decrypt text function, omitting `offset` parameter
    """
    assert Ceasar.decrypt("abdef") == "abdef"