def testGatherMetadataWmsInvalidXml(self): self.maxDiff = None # An WMS response with invalid XML. self.assertTrue( metadata_fetch.GatherMetadata( 'WMS', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=INVALID_XML_WMS_RESPONSE))['ill_formed'])
def testGatherMetadataWmsInvalid(self): self.maxDiff = None # An invalid WMS response that is valid XML. self.assertEquals({}, metadata_fetch.GatherMetadata( 'WMS', utils.Struct( status_code=200, headers=RESPONSE_HEADERS, content=INVALID_WMS_RESPONSE))['wms_layers'])
def testGatherMetadataWmsValid(self): self.maxDiff = None # A valid WMS GetCapabilities response. self.assertEquals( METADATA_VALID_WMS_RESPONSE, metadata_fetch.GatherMetadata( 'WMS', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=VALID_WMS_RESPONSE))['wms_layers']) # A response with a valid layer and several invalid Layers. self.assertEquals( METADATA_INVALID_LAYERS_WMS_RESPONSE, metadata_fetch.GatherMetadata( 'WMS', utils.Struct( status_code=200, headers=RESPONSE_HEADERS, content=INVALID_LAYERS_WMS_RESPONSE))['wms_layers'])
def testGatherMetadataKmz(self): # KMZ containing valid KML. kmz = CreateZip([('doc.kml', SIMPLE_KML)]) self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(kmz), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'update_time': LAST_MODIFIED_TIMESTAMP, 'length': len(kmz), 'md5_hash': hashlib.md5(kmz).hexdigest() }, metadata_fetch.GatherMetadata( 'KML', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=kmz))) # KMZ containing valid KML with unsupported features. content = '<kml><Document><Placemark><Camera/></Placemark></Document></kml>' kmz = CreateZip([('doc.kml', content)]) self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(kmz), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'update_time': LAST_MODIFIED_TIMESTAMP, 'length': len(kmz), 'md5_hash': hashlib.md5(kmz).hexdigest(), 'has_unsupported_kml': True }, metadata_fetch.GatherMetadata( 'KML', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=kmz)))
def testGatherMetadataGeorss(self): # Valid GeoRSS. content = '<rss><channel><item></item></channel></rss>' self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(content), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'update_time': LAST_MODIFIED_TIMESTAMP, 'length': len(content), 'md5_hash': hashlib.md5(content).hexdigest() }, metadata_fetch.GatherMetadata( 'GEORSS', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=content))) # Valid GeoRSS with no features. content = '<rss><channel></channel></rss>' self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(content), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'update_time': LAST_MODIFIED_TIMESTAMP, 'length': len(content), 'md5_hash': hashlib.md5(content).hexdigest(), 'has_no_features': True }, metadata_fetch.GatherMetadata( 'GEORSS', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=content)))
def testGatherMetadataInvalid(self): # Invalid XML syntax. content = '<blah' self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(content), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'update_time': LAST_MODIFIED_TIMESTAMP, 'length': len(content), 'md5_hash': hashlib.md5(content).hexdigest(), 'ill_formed': True }, metadata_fetch.GatherMetadata( 'KML', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=content)))
def testGatherMetadataKml(self): # Valid KML. self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(SIMPLE_KML), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'update_time': LAST_MODIFIED_TIMESTAMP, 'length': len(SIMPLE_KML), 'md5_hash': hashlib.md5(SIMPLE_KML).hexdigest() }, metadata_fetch.GatherMetadata( 'KML', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=SIMPLE_KML))) # Valid KML with no features. content = '<kml><Document></Document></kml>' self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(content), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'update_time': LAST_MODIFIED_TIMESTAMP, 'length': len(content), 'md5_hash': hashlib.md5(content).hexdigest(), 'has_no_features': True }, metadata_fetch.GatherMetadata( 'KML', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=content))) # Valid KML with unsupported features. content = '<kml><Document><Placemark><Camera/></Placemark></Document></kml>' self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(content), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'update_time': LAST_MODIFIED_TIMESTAMP, 'length': len(content), 'md5_hash': hashlib.md5(content).hexdigest(), 'has_unsupported_kml': True }, metadata_fetch.GatherMetadata( 'KML', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=content))) # Valid KML with a NetworkLink, but no ETag or Last-modified header. content = '<kml><Document><NetworkLink/></Document></kml>' self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(content), 'length': len(content), 'md5_hash': hashlib.md5(content).hexdigest() }, metadata_fetch.GatherMetadata( 'KML', utils.Struct(status_code=200, headers={}, content=content))) # Valid KML with a NetworkLink, which invalidates the update time. content = '<kml><Document><NetworkLink/></Document></kml>' self.assertEquals( { 'fetch_status': 200, 'fetch_length': len(content), 'fetch_last_modified': LAST_MODIFIED_STRING, 'fetch_etag': ETAG, 'length': len(content), 'md5_hash': hashlib.md5(content).hexdigest() }, metadata_fetch.GatherMetadata( 'KML', utils.Struct(status_code=200, headers=RESPONSE_HEADERS, content=content)))