def test_mvt_layer(self): layer_name = 'mvt_test' req_url = 'http://localhost/onearth/test/wmts/wmts.cgi?layer={0}&tilematrixset=EPSG4326_16km&Service=WMTS&Request=GetTile&Version=1.0.0&Format=application%2Fx-protobuf&TileMatrix=0&TileCol=0&TileRow=0&TIME=2012-01-01'.format(layer_name) if DEBUG: print '\nTesting for Valid MVT Tile' mvt_tile = get_url(req_url) self.assertTrue(check_valid_mvt(mvt_tile), 'Output tile for MVT test layer is not a valid MVT tile.')
def test_wfs_get_capabilities_2_0_0(self): """ 10. FAIL!!! Request WFS GetCapabilities 2.0.0 """ ref_hash = '74541c28d6b94185c1139073b309dd29' req_url = 'http://localhost/onearth/test/wfs/mapserv?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetCapabilities' if DEBUG: print '\nTesting WFS GetCapablities 2.0.0' print 'URL: ' + req_url response = get_url(req_url) # Check if the response is valid XML try: XMLroot = ElementTree.XML(response.read()) XMLdict = XmlDictConfig(XMLroot) xml_check = True except: xml_check = False self.assertTrue(xml_check, 'WMS GetCapabilities 2.0.0 response is not a valid XML file. URL: ' + req_url) refXMLtree = ElementTree.parse(os.path.join(os.getcwd(), 'mod_onearth_test_data/GetCapabilities.2.0.0.xml')) refXMLroot = refXMLtree.getroot() refXMLdict = XmlDictConfig(refXMLroot) check_result = check_dicts(XMLdict, refXMLdict) self.assertTrue(check_result, 'WFS Get GetCapabilities Request 2.0.0 does not match what\'s expected. URL: ' + req_url)
def test_wms_get_capabilities_1_3_0(self): """ 9. FAIL!!! Request WMS GetCapabilities 1.3.0 """ ref_hash = 'dfbd4b79796c78db32df08eddc8ff14c' req_url = 'http://localhost/onearth/test/wms/mapserv?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities' if DEBUG: print '\nTesting WMS GetCapablities 1.3.0' print 'URL: ' + req_url response = get_url(req_url) # Check if the response is valid XML try: XMLroot = ElementTree.XML(response.read()) XMLdict = XmlDictConfig(XMLroot) xml_check = True except: xml_check = False self.assertTrue(xml_check, 'WMS GetCapabilities 1.3.0 response is not a valid XML file. URL: ' + req_url) refXMLtree = ElementTree.parse(os.path.join(os.getcwd(), 'mod_onearth_test_data/GetCapabilities.1.3.0.xml')) refXMLroot = refXMLtree.getroot() refXMLdict = XmlDictConfig(refXMLroot) check_result = check_dicts(XMLdict, refXMLdict) self.assertTrue(check_result, 'WMS Get GetCapabilities Request 1.3.0 does not match what\'s expected. URL: ' + req_url)
def test_wms_get_capabilities_1_1_1(self): """ 8. Request WMS GetCapabilities 1.1.1 """ ref_hash = '91d5f50860dc4324a805791191683588' req_url = 'http://localhost/onearth/test/wms/mapserv?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities' if DEBUG: print '\nTesting WMS GetCapablities 1.1.1' print 'URL: ' + req_url response = get_url(req_url) # Check if the response is valid XML try: XMLroot = ElementTree.XML(response.read()) XMLdict = XmlDictConfig(XMLroot) xml_check = True except: xml_check = False self.assertTrue(xml_check, 'WMS GetCapabilities 1.1.1 response is not a valid XML file. URL: ' + req_url) refXMLtree = ElementTree.parse(os.path.join(os.getcwd(), 'mod_onearth_test_data/GetCapabilities.1.1.1.xml')) refXMLroot = refXMLtree.getroot() refXMLdict = XmlDictConfig(refXMLroot) check_result = check_dicts(XMLdict, refXMLdict) self.assertTrue(check_result, 'WMS Get GetCapabilities 1.1.1 Request does not match what\'s expected. URL: ' + req_url)
def test_request_date_kml(self): """ 14. Request tile with date via KML """ # Note that we can't directly test the KML against a hash as the generated file changes based on the server settings req_url = 'http://localhost/onearth/test/twms/kmlgen.cgi?layers=test_weekly_jpg&time=2012-02-29' search_string = '<name>2012-02-29 test_weekly_jpg</name>' if DEBUG: print '\nTesting: Request tile with date via KML' print 'URL: ' + req_url response = get_url(req_url) # Check if the response is valid XML try: xml.dom.minidom.parse(response) xml_check = True except xml.parsers.expat.ExpatError: xml_check = False self.assertTrue( xml_check, 'KML response is not a valid XML file. URL: ' + req_url) # Check if layer name is in KML result check_result = all(line for line in response if search_string in line) self.assertTrue( check_result, 'Layer name not found in KML date request. URL: ' + req_url)
def test_request_wfs_geojson_with_time(self): """ 24. Request GeoJSON from vector source file with time via WFS """ ref_hash = 'd28dab255366e4bf69d8eaf6d649d930' req_url = 'http://localhost/onearth/test/wms/mapserv?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAME=Terra_Orbit_Dsc_Dots&OUTPUTFORMAT=geojson&TIME=2016-03-05' if DEBUG: print '\nTesting: Request GeoJSON from vector source file with time via WFS' print 'URL: ' + req_url response = get_url(req_url) # Check if the response is valid JSON try: JSONdict = json.loads(response.read()) JSON_check = True except Error: JSON_check = False self.assertTrue( JSON_check, 'WFS with time GeoJSON response is not a valid JSON file. URL: ' + req_url) with open( os.path.join( os.getcwd(), 'mod_onearth_test_data/wfs_geojson_time.txt')) as JSONfile: refJSONdict = json.load(JSONfile) check_result = check_dicts(JSONdict, refJSONdict) self.assertTrue( check_result, 'WMS request GeoJSON from vector source file with time via WFS does not match what\'s expected. URL: ' + req_url)
def test_bad_bbox_value(self): test_url = base_url + '/test_mod_reproject_twms_err/twms.cgi?request=GetMap&layers=test_weekly_jpg&srs=EPSG:4326&format=image%2Fjpeg&styles=&&width=512&height=512&bbox=-180,-198,10' response = get_url(test_url) # Check if the response is valid XML try: XMLroot = ElementTree.XML(response.read()) xml_check = True except: xml_check = False self.assertTrue( xml_check, 'TWMS response is not a valid XML file. URL: ' + test_url) exception = XMLroot.find('ServiceException').text print exception check_str = exception.find('WMS parameter bbox format incorrect') error = 'The TWMS response does not match what\'s expected. URL: {0}'.format( test_url) self.assertTrue(check_str, error)
def test_request_date_kml(self): """ 14. Request tile with date via KML """ # Note that we can't directly test the KML against a hash as the generated file changes based on the server settings req_url = 'http://localhost/onearth/test/twms/kmlgen.cgi?layers=test_weekly_jpg&time=2012-02-29' search_string = '<name>2012-02-29 test_weekly_jpg</name>' if DEBUG: print '\nTesting: Request tile with date via KML' print 'URL: ' + req_url response = get_url(req_url) # Check if the response is valid XML try: xml.dom.minidom.parse(response) xml_check = True except xml.parsers.expat.ExpatError: xml_check = False self.assertTrue(xml_check, 'KML response is not a valid XML file. URL: ' + req_url) # Check if layer name is in KML result check_result = all(line for line in response if search_string in line) self.assertTrue(check_result, 'Layer name not found in KML date request. URL: ' + req_url)
def test_request_wfs_geojson_with_time(self): """ 24. Request GeoJSON from vector source file with time via WFS """ ref_hash = 'd28dab255366e4bf69d8eaf6d649d930' req_url = 'http://localhost/onearth/test/wms/mapserv?SERVICE=WFS&VERSION=2.0.0&REQUEST=GetFeature&TYPENAME=Terra_Orbit_Dsc_Dots&OUTPUTFORMAT=geojson&TIME=2016-03-05' if DEBUG: print '\nTesting: Request GeoJSON from vector source file with time via WFS' print 'URL: ' + req_url response = get_url(req_url) # Check if the response is valid JSON try: JSONdict = json.loads(response.read()) JSON_check = True except Error: JSON_check = False self.assertTrue(JSON_check, 'WFS with time GeoJSON response is not a valid JSON file. URL: ' + req_url) with open(os.path.join(os.getcwd(), 'mod_onearth_test_data/wfs_geojson_time.txt')) as JSONfile: refJSONdict = json.load(JSONfile) check_result = check_dicts(JSONdict, refJSONdict) self.assertTrue(check_result, 'WMS request GeoJSON from vector source file with time via WFS does not match what\'s expected. URL: ' + req_url)