'Verify that GeoNode CSW can handle FGDC metadata upload'

def test_csw_upload_fgdc(self):

    csw = get_catalogue()
    if (csw.catalogue.type == 'pycsw_http'):
        md_doc = etree.tostring(etree.fromstring(open(os.path.join(gisdata.GOOD_METADATA, 'sangis.org', 'Census', 'Census_Blockgroup_Pop_Housing.shp.xml')).read()))
        csw.catalogue.transaction(ttype='insert', typename='fgdc:metadata', record=md_doc)
        self.assertEqual(csw.catalogue.results['inserted'], 1, 'Expected    1    inserted    record    in    FGDC    model')
        csw.catalogue.getrecords(typenames='fgdc:metadata')
        self.assertEqual(csw.catalogue.results['matches'], 1, 'Expected    1    record    in    FGDC    model')
        record = csw.catalogue.records.values()[0]
        self.assertEqual(record.title, 'Census_Blockgroup_Pop_Housing', 'Expected    a    specific    title    in    DC    model')
        self.assertEqual(record.type, 'vector    digital    data', 'Expected    a    specific    type    in    DC    model')
        self.assertEqual(record.bbox.crs.code, 4326, 'Expected    a    specific    CRS    code    value    in    Dublin    Core    model')
        self.assertEqual(record.bbox.minx, '-117.6', 'Expected    a    specific    minx    coordinate    value    in    Dublin    Core    model')
        self.assertEqual(record.bbox.miny, '32.53', 'Expected    a    specific    minx    coordinate    value    in    Dublin    Core    model')
        self.assertEqual(record.bbox.maxx, '-116.08', 'Expected    a    specific    maxx    coordinate    value    in    Dublin    Core    model')
        self.assertEqual(record.bbox.maxy, '33.51', 'Expected    a    specific    maxy    coordinate    value    in    Dublin    Core    model')
        csw.catalogue.getrecords(typenames='fgdc:metadata', esn='brief', outputschema='http://www.isotc211.org/2005/gmd')
        self.assertEqual(csw.catalogue.results['matches'], 1, 'Expected    1    record    in    ISO    model')
        record = csw.catalogue.records.values()[0]
        self.assertEqual(record.identification.title, 'Census_Blockgroup_Pop_Housing', 'Expected    a    specific    title    in    ISO    model')
        csw.catalogue.transaction(ttype='delete', typename='fgdc:metadata', cql='fgdc:Title    like    "Census_Blockgroup_Pop_Housing"')
        self.assertEqual(csw.catalogue.results['deleted'], 1, 'Expected    1    deleted    record    in    FGDC    model')
