def test_xml_to_json_to_xml(self): generated_metadata = OutputLayerMetadata(EXISTING_IMPACT_FILE, xml_uri=EXISTING_IMPACT_XML) with open(EXISTING_IMPACT_XML) as f: expected_metadata = f.read() json_tmp_file = unique_filename(suffix='.json', dir=TEMP_DIR) generated_metadata.write_to_file(json_tmp_file) read_tmp_metadata = OutputLayerMetadata(EXISTING_IMPACT_FILE, json_uri=json_tmp_file) self.assertEquals(expected_metadata, read_tmp_metadata.xml)
def test_xml_to_json_to_xml(self): generated_metadata = OutputLayerMetadata( EXISTING_IMPACT_FILE, xml_uri=EXISTING_IMPACT_XML ) with open(EXISTING_IMPACT_XML) as f: expected_metadata = f.read() json_tmp_file = unique_filename(suffix='.json', dir=TEMP_DIR) generated_metadata.write_to_file(json_tmp_file) read_tmp_metadata = OutputLayerMetadata( EXISTING_IMPACT_FILE, json_uri=json_tmp_file ) self.assertEquals(expected_metadata, read_tmp_metadata.xml)
def test_xml_to_json_to_xml(self): generated_metadata = OutputLayerMetadata(EXISTING_IMPACT_FILE, xml_uri=EXISTING_IMPACT_XML) with open(EXISTING_IMPACT_XML) as f: expected_metadata = f.read() json_tmp_file = unique_filename(suffix='.json', dir=TEMP_DIR) generated_metadata.write_to_file(json_tmp_file) read_tmp_metadata = OutputLayerMetadata(EXISTING_IMPACT_FILE, json_uri=json_tmp_file) # Unless we want to add a specialized library, this # is the best we can do with what python offers self.assertEqual(sorted(expected_metadata.split('\n')), sorted(read_tmp_metadata.xml.split('\n')))
def test_xml_to_json_to_xml(self): generated_metadata = OutputLayerMetadata( EXISTING_IMPACT_FILE, xml_uri=EXISTING_IMPACT_XML ) with open(EXISTING_IMPACT_XML) as f: expected_metadata = f.read() json_tmp_file = unique_filename(suffix='.json', dir=TEMP_DIR) generated_metadata.write_to_file(json_tmp_file) read_tmp_metadata = OutputLayerMetadata( EXISTING_IMPACT_FILE, json_uri=json_tmp_file ) # Unless we want to add a specialized library, this # is the best we can do with what python offers self.assertEqual(sorted(expected_metadata.split('\n')), sorted(read_tmp_metadata.xml.split('\n')))