'Verify that GeoNode CSW can handle bulk upload of ISO and FGDC metadata'

def test_csw_bulk_upload(self):

    csw = get_catalogue()
    if (csw.catalogue.type == 'pycsw_http'):
        identifiers = []
        for (root, dirs, files) in os.walk(os.path.join(gisdata.GOOD_METADATA, 'sangis.org')):
            for mfile in files:
                if mfile.endswith('.xml'):
                    md_doc = etree.tostring(etree.fromstring(open(os.path.join(root, mfile)).read()))
                    csw.catalogue.transaction(ttype='insert', typename='fgdc:metadata', record=md_doc)
                    identifiers.append(csw.catalogue.results['insertresults'][0])
        for md in glob.glob(os.path.join(gisdata.GOOD_METADATA, 'wustl.edu', '*.xml')):
            md_doc = etree.tostring(etree.fromstring(open(md).read()))
            csw.catalogue.transaction(ttype='insert', typename='gmd:MD_Metadata', record=md_doc)
            identifiers.append(csw.catalogue.results['insertresults'][0])
        csw.catalogue.getrecords(typenames='fgdc:metadata')
        self.assertEqual(csw.catalogue.results['matches'], 72, 'Expected    187    records    in    FGDC    model')
        csw.catalogue.getrecords(typenames='gmd:MD_Metadata')
        self.assertEqual(csw.catalogue.results['matches'], 115, 'Expected    194    records    in    ISO    model')
        csw.catalogue.getrecords(typenames='gmd:MD_Metadata    fgdc:metadata')
        self.assertEqual(csw.catalogue.results['matches'], 187, 'Expected    381    records    total    in    FGDC    and    ISO    model')
        for i in identifiers:
            csw.catalogue.transaction(ttype='delete', identifier=i)
