Ejemplo n.º 1
0
 def test_is_reversible(self):
     cipher = Cipher('abcdefghij')
     plaintext = 'abcdefghij'
     self.assertEqual(cipher.decode(cipher.encode(plaintext)), plaintext)
Ejemplo n.º 2
0
 def test_can_decode(self):
     cipher = Cipher('abcdefghij')
     self.assertEqual(cipher.decode(cipher.key), 'aaaaaaaaaa')
Ejemplo n.º 3
0
 def test_can_decode(self):
     cipher = Cipher('abcdefghij')
     self.assertEqual(cipher.decode(cipher.key), 'aaaaaaaaaa')
 def test_decode_with_10_shift_distance(self):
     cipher = Cipher()
     plaintext = 'ghijklmn'
     ciphertext = 'wxyzabcd'
     self.assertEqual(ciphertext, cipher.decode(plaintext, 10))
 def test_decode_with_27_shift_distance(self):
     cipher = Cipher()
     plaintext = 'xyzabcde'
     ciphertext = 'wxyzabcd'
     self.assertEqual(ciphertext, cipher.decode(plaintext, 27))
 def test_decode_raise_error_if_non_letter_characters(self):
     cipher = Cipher()
     plaintext = 'az4'
     with pytest.raises(Exception):
         cipher.decode(plaintext)
 def test_decode_wraps_a_to_z(self):
     cipher = Cipher()
     plaintext = 'a'
     ciphertext = 'z'
     self.assertEqual(ciphertext, cipher.decode(plaintext))
Ejemplo n.º 8
0
 def test_can_decode_messages_longer_than_the_key(self):
     cipher = Cipher("abc")
     self.assertEqual(cipher.decode("iboaqcnecbfcr"), "iamapandabear")
Ejemplo n.º 9
0
 def test_cipher_compositiion1(self):
     key = ('duxrceqyaimciuucnelkeoxjhdyduucpmrxmaivacmybmsdrzwqxvbxsy'
            'gzsabdjmdjabeorttiwinfrpmpogvabiofqexnohrqu')
     plaintext = 'adaywithoutlaughterisadaywasted'
     c = Cipher(key)
     self.assertEqual(plaintext, c.decode(c.encode(plaintext)))
Ejemplo n.º 10
0
 def test_can_decode(self):
     cipher = Cipher("abcdefghij")
     self.assertEqual(cipher.decode(cipher.key), "aaaaaaaaaa")
Ejemplo n.º 11
0
 def test_can_wrap_on_decode(self):
     cipher = Cipher("abcdefghij")
     self.assertEqual(cipher.decode("zabcdefghi"), "zzzzzzzzzz")
Ejemplo n.º 12
0
 def test_can_decode(self):
     cipher = Cipher()
     self.assertEqual(cipher.decode(cipher.key[0:len("aaaaaaaaaa")]),
                      "aaaaaaaaaa")
Ejemplo n.º 13
0
 def test_can_wrap_on_decode(self):
     cipher = Cipher('abcdefghij')
     self.assertEqual(cipher.decode('zabcdefghi'), 'zzzzzzzzzz')
Ejemplo n.º 14
0
 def test_is_reversible(self):
     cipher = Cipher('abcdefghij')
     plaintext = 'abcdefghij'
     self.assertEqual(cipher.decode(cipher.encode(plaintext)), plaintext)
Ejemplo n.º 15
0
 def test_can_wrap_on_decode(self):
     cipher = Cipher('abcdefghij')
     self.assertEqual(cipher.decode('zabcdefghi'), 'zzzzzzzzzz')
Ejemplo n.º 16
0
 def test_cipher_compositiion2(self):
     plaintext = 'adaywithoutlaughterisadaywasted'
     c = Cipher()
     self.assertEqual(plaintext, c.decode(c.encode(plaintext)))
Ejemplo n.º 17
0
 def test_can_decode_messages_longer_than_key(self):
     cipher = Cipher('abc')
     self.assertEqual(cipher.decode('iboaqcnecbfcr'), 'iamapandabear')
Ejemplo n.º 18
0
 def test_cipher_combo_short_key(self):
     text = 'awbxcydz'
     c = Cipher('abcd')
     cipher = c.encode(text)
     self.assertEqual(cipher, 'axdaczfc')
     self.assertEqual(c.decode(cipher), text)
 def test_decode_letter_with_default_shift_distance(self):
     cipher = Cipher()
     plaintext = 'b'
     ciphertext = 'a'
     self.assertEqual(ciphertext, cipher.decode(plaintext))
Ejemplo n.º 20
0
 def test_cipher_compositiion1(self):
     key = ('duxrceqyaimciuucnelkeoxjhdyduucpmrxmaivacmybmsdrzwqxvbxsy'
            'gzsabdjmdjabeorttiwinfrpmpogvabiofqexnohrqu')
     plaintext = 'adaywithoutlaughterisadaywasted'
     c = Cipher(key)
     self.assertEqual(c.decode(c.encode(plaintext)), plaintext)
 def test_decode_string_with_default_shift_distance(self):
     cipher = Cipher()
     plaintext = 'xyzabcde'
     ciphertext = 'wxyzabcd'
     self.assertEqual(ciphertext, cipher.decode(plaintext))
Ejemplo n.º 22
0
 def test_cipher_compositiion2(self):
     plaintext = 'adaywithoutlaughterisadaywasted'
     c = Cipher()
     self.assertEqual(c.decode(c.encode(plaintext)), plaintext)
 def test_decode_with_26_shift_distance(self):
     cipher = Cipher()
     plaintext = 'klmnopqrst'
     ciphertext = 'klmnopqrst'
     self.assertEqual(ciphertext, cipher.decode(plaintext, 26))
Ejemplo n.º 24
0
 def test_can_decode(self):
     cipher = Cipher()
     plaintext = 'aaaaaaaaaa'
     self.assertEqual(cipher.decode(cipher.key[:len(plaintext)]), plaintext)
 def test_decode_always_returns_downcase_string(self):
     cipher = Cipher()
     plaintext = 'BcDeFgHiJk'
     ciphertext = 'abcdefghij'
     self.assertEqual(ciphertext, cipher.decode(plaintext))
Ejemplo n.º 26
0
 def test_can_decode(self):
     cipher = Cipher()
     plaintext = 'aaaaaaaaaa'
     self.assertEqual(cipher.decode(cipher.key[:len(plaintext)]), plaintext)