class CaesarCipherTestCase(unittest.TestCase): def setUp(self): self.cipher = CaesarCipher() def test_should_get_fulswrjudild_to_criptografia_word(self): assert_equals(self.cipher.encrypt("criptografia"), "fulswrjudild") def test_should_get_criptografia_when_decoded_criptografia_word(self): encrypted = self.cipher.encrypt("criptografia") assert_equals(self.cipher.decrypt(encrypted), "criptografia") def test_should_get_zope_when_decoded_zope_word(self): encrypted = self.cipher.encrypt("zope") assert_equals(self.cipher.decrypt(encrypted), "zope") def test_should_get_warm_when_decoded_warm_word(self): encrypted = self.cipher.encrypt("warm") assert_equals(self.cipher.decrypt(encrypted), "warm") def test_should_get_xmen_when_decoded_xmen_word(self): encrypted = self.cipher.encrypt("xmen") assert_equals(self.cipher.decrypt(encrypted), "xmen") def test_should_get_livelongandprosper_when_decoded_livelongandprosper_word( self): encrypted = self.cipher.encrypt("livelongandprosper") assert_equals(self.cipher.decrypt(encrypted), "livelongandprosper") def test_should_get_zope_when_decoded_zope_word_with_a_7_key_value(self): cipher = CaesarCipher(7) encrypted = cipher.encrypt("zope") assert_equals(cipher.decrypt(encrypted), "zope")
class CaesarCipherTestCase(unittest.TestCase): def setUp(self): self.cipher = CaesarCipher() def test_should_get_fulswrjudild_to_criptografia_word(self): assert_equals(self.cipher.encrypt("criptografia"), "fulswrjudild") def test_should_get_criptografia_when_decoded_criptografia_word(self): encrypted = self.cipher.encrypt("criptografia") assert_equals(self.cipher.decrypt(encrypted), "criptografia") def test_should_get_zope_when_decoded_zope_word(self): encrypted = self.cipher.encrypt("zope") assert_equals(self.cipher.decrypt(encrypted), "zope") def test_should_get_warm_when_decoded_warm_word(self): encrypted = self.cipher.encrypt("warm") assert_equals(self.cipher.decrypt(encrypted), "warm") def test_should_get_xmen_when_decoded_xmen_word(self): encrypted = self.cipher.encrypt("xmen") assert_equals(self.cipher.decrypt(encrypted), "xmen") def test_should_get_livelongandprosper_when_decoded_livelongandprosper_word(self): encrypted = self.cipher.encrypt("livelongandprosper") assert_equals(self.cipher.decrypt(encrypted), "livelongandprosper") def test_should_get_zope_when_decoded_zope_word_with_a_7_key_value(self): cipher = CaesarCipher(7) encrypted = cipher.encrypt("zope") assert_equals(cipher.decrypt(encrypted), "zope")
class TestDecryptString(unittest.TestCase): def setUp(self): self.message = CaesarCipher(CIPHER, SHIFT_BY) def test_isinstance(self): self.assertIsInstance(self.message, CaesarCipher) def test_decrypt(self): check = self.message.decrypt() expect = PLAIN.upper() self.assertEquals(check, expect)
def main(process, key, input_file, output_file): with open(input_file, "r") as f: text = f.read() cipher_obj = CaesarCipher() if process == "encrypt": result = cipher_obj.encrypt(text, key) elif process == "decrypt": result = cipher_obj.decrypt(text, key) else: raise Exception("No such process") with open(output_file, "w") as f: f.write(result)
def test_should_get_zope_when_decoded_zope_word_with_a_7_key_value(self): cipher = CaesarCipher(7) encrypted = cipher.encrypt("zope") assert_equals(cipher.decrypt(encrypted), "zope")