def test_to_string_with_none(self): # Given nothing is passed # When to_str is called s = to_str(None) # Then None is returned self.assertEqual(s, None)
def test_to_string_with_bytes(self): # Given a bytes stream is passed byte_stream = b"klm" # When to_str is called s = to_str(byte_stream) # Then a string is returned self.assertEqual(s, "klm")
def test_to_string_with_string(self): # Given a string is passed string = "hij" # When to_str is called s = to_str(string) # Then a string is returned self.assertEqual(s, "hij")
def encrypt(self, payload): """ Encrypts the payload using the keystore values :param payload: the value to encrypt :return: string of encrypted data """ encrypted_data = encrypt(payload, key_store=self.keystore, key_purpose=KEY_PURPOSE) return to_str(encrypted_data)