def testRound(self): a = EncryptedMessage.to_json(self.enc) e2 = EncryptedMessage.from_json(a) self.assertEqual(self.enc, e2) b = EncryptedMessage.to_binary(e2) e3 = EncryptedMessage.from_binary(b) self.assertEqual(e3, e2) c = EncryptedMessage.to_ascii(e2) e4 = EncryptedMessage.from_ascii(c) self.assertEqual(e4, self.enc)
def testMismatches(self): j = EncryptedMessage.to_json(self.enc) b = EncryptedMessage.to_binary(self.enc) a = EncryptedMessage.to_ascii(self.enc) with self.assertRaises(Exception) as context: EncryptedMessage.from_json(b) with self.assertRaises(Exception) as context: EncryptedMessage.from_json(a) with self.assertRaises(Exception) as context: EncryptedMessage.from_binary(j) with self.assertRaises(Exception) as context: EncryptedMessage.from_binary(a) with self.assertRaises(Exception) as context: EncryptedMessage.from_ascii(j) with self.assertRaises(Exception) as context: EncryptedMessage.from_ascii(b)
def testJson(self): a = EncryptedMessage.to_json(self.enc) e2 = EncryptedMessage.from_json(a) self.assertEqual(self.enc, e2)