def test_dumps(self): ref = Entity() stream = StringIO() ref.dump(stream, SUPER_SECURE_PASSWORD) stream.seek(0) other = Entity.load(stream, SUPER_SECURE_PASSWORD) self.assertEqual(ref.private_key, other.private_key)
def test_prompt_load(self): ref = Entity() stream = StringIO() # write the entity to the stream ref.dump(stream, SUPER_SECURE_PASSWORD) # reset the stream stream.seek(0) with patch('getpass.getpass') as mock_getpass: mock_getpass.side_effect = [SUPER_SECURE_PASSWORD] other = Entity.prompt_load(stream) self.assertEqual(other.private_key, ref.private_key)