From 4a2e7d827ab599cc6c798d04365e8f52f21b97b7 Mon Sep 17 00:00:00 2001 From: d-w-moore Date: Wed, 13 Nov 2024 09:47:36 -0500 Subject: [PATCH] [_582] check that xml_mode solves issue of nonprintables in metadata --- irods/test/meta_test.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/irods/test/meta_test.py b/irods/test/meta_test.py index f398a87a..7be4b1c4 100644 --- a/irods/test/meta_test.py +++ b/irods/test/meta_test.py @@ -1,6 +1,7 @@ #! /usr/bin/env python # -*- coding: utf-8 -*- +import contextlib import os import re import sys @@ -646,6 +647,27 @@ def test_thoroughgoing_correctness_of_genquery_result_column_mappings__issue_642 finally: del test_coll.metadata[meta_key] + def test_xml_mode_addresses_odd_metadata_characters__issue_582(self): + session = self.sess + try: + hexvalue = "53:6b:6f:70:65:43:61:6c:58:c3:af:c2:bf:c2:bd:c3:af:c2:bf:c2:bd:23:01:32:64:31" + hex_list = [int(byte, 16) for byte in hexvalue.split(":")] + string_value = "".join([chr(byte) for byte in hex_list]) + + try: + from irods.helpers import xml_mode + except ImportError: + # Create an xml_mode context manager that is a no-op. + def _dummy(*x): yield + xml_mode = contextlib.contextmanager(_dummy) + + with xml_mode('QUASI_XML'): + obj = session.collections.get('/tempZone/home/rods') + attr_str = "awesome" + value_str = string_value + obj.metadata.add( attr_str, value_str ) + finally: + del obj.metadata[attr_str] if __name__ == '__main__': # let the tests find the parent irods lib