def testAllNormalizations(self, untl_dict=UNNORMALIZED_DICT, normalized_dict=NORMALIZED_DICT): """Test all the normalizations for UNTL.""" normalize_required = { 'subject': ['LCSH', 'UNTL-BS'], } norm = untldict_normalizer(untl_dict, normalize_required) self.assertEqual(norm, normalized_dict)
def testSingleNormalization(self, untl_dict=UNNORMALIZED_DICT, normalized_dict=NORMALIZED_DICT): """Test normalizing LCSH UNTL data.""" normalize_required = { 'subject': ['LCSH'], } norm = untldict_normalizer(untl_dict, normalize_required) self.assertEqual(norm, normalized_dict)
def get_desc_metadata(metadata_filename, metadata_type): """ Get the descriptive metadata for the object """ # Open and read the metadata file into a StringIO filehandle metadata_filehandle = open_system_file(metadata_filename) metadata_stringfile = StringIO.StringIO(metadata_filehandle.read()) if metadata_type == 'UNTL': # Get the untl descriptive metadata dictionary desc_metadata = untlxml2pydict(metadata_stringfile) normalize_required = { 'subject': ['LCSH', 'UNTL-BS'], } # Normalize the values in the untl dictionary normalized_metadata = untldict_normalizer( desc_metadata, normalize_required, ) return normalized_metadata else: raise ResourceObjectException("Not a supported descriptive " + "metadata type.")