예제 #1
0
class TestOnline(object):
    """Class grouping online tests for the WFS get_schema method."""
    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WFS_SERVICE_URL),
                        reason="WFS service is unreachable")
    @pytest.mark.parametrize("wfs_version", ["1.1.0", "2.0.0"])
    def test_get_schema(self, wfs_version):
        """Test the get_schema method for a standard schema."""
        wfs = WebFeatureService(WFS_SERVICE_URL, version=wfs_version)
        schema = wfs.get_schema('dov-pub:Boringen')

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WFS_SERVICE_URL),
                        reason="WFS service is unreachable")
    @pytest.mark.parametrize("wfs_version", ["1.1.0", "2.0.0"])
    def test_schema_result(self, wfs_version):
        """Test whether the output from get_schema is a wellformed dictionary."""
        wfs = WebFeatureService(WFS_SERVICE_URL, version=wfs_version)
        schema = wfs.get_schema('dov-pub:Boringen')
        assert isinstance(schema, dict)

        assert 'properties' in schema or 'geometry' in schema

        if 'geometry' in schema:
            assert 'geometry_column' in schema

        if 'properties' in schema:
            assert isinstance(schema['properties'], dict)

        assert 'required' in schema
        assert isinstance(schema['required'], list)
예제 #2
0
from tests.utils import scratch_file
from tests.utils import service_ok

import pytest

SERVICE_URL = 'http://map1c.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi'


@pytest.mark.online
@pytest.mark.skipif(not service_ok(SERVICE_URL),
                    reason="WMTS service is unreachable")
def test_wmts():
    # Find out what a WMTS has to offer. Service metadata:
    from owslib.wmts import WebMapTileService
    wmts = WebMapTileService(SERVICE_URL)
    assert wmts.identification.type == 'OGC WMTS'
    assert wmts.identification.version == '1.0.0'
    assert wmts.identification.title == 'NASA Global Imagery Browse Services for EOSDIS'
    bytearray(wmts.identification.abstract, 'utf-8')
    bytearray(b'Near real time imagery from multiple NASA instruments')
    assert wmts.identification.keywords == ['World', 'Global']
    # Service Provider:
    assert wmts.provider.name == 'National Aeronautics and Space Administration'
    assert wmts.provider.url == 'https://earthdata.nasa.gov/'
    # Available Layers:
    assert len(wmts.contents.keys()) > 0
    assert sorted(list(wmts.contents))[0] == 'AIRS_CO_Total_Column_Day'
    # Fetch a tile (using some defaults):
    tile = wmts.gettile(layer='MODIS_Terra_CorrectedReflectance_TrueColor',
                        tilematrixset='EPSG4326_250m',
                        tilematrix='0',
예제 #3
0
import pytest
from tests.utils import service_ok

from owslib.wms import WebMapService
from owslib.util import ServiceException
from owslib.util import ResponseWrapper


SERVICE_URL = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r-t.cgi'
NCWMS2_URL = "http://wms.stccmop.org:8080/ncWMS2/wms"


@pytest.mark.online
@pytest.mark.skipif(not service_ok(SERVICE_URL),
                    reason="WMS service is unreachable")
def test_wms_getmap_111():
    """MESONET GetMap 1.1.1"""
    wms = WebMapService(SERVICE_URL, version='1.1.1')
    assert wms.request == '{}?service=WMS&request=GetCapabilities&version=1.1.1'.format(SERVICE_URL)
    rsp = wms.getmap(
        layers=['nexrad_base_reflect'],
        styles=['default'],
        srs='EPSG:4326',
        bbox=(-126, 24, -66, 50),
        size=(250, 250),
        format='image/jpeg',
        transparent=True)
    import owslib.util
    assert type(rsp) is ResponseWrapper

예제 #4
0
from tests.utils import service_ok

import pytest

from owslib.wfs import WebFeatureService

SERVICE_URL = 'https://www.ldproxy.nrw.de/rest/services/kataster/?f=json'


@pytest.mark.online
@pytest.mark.skipif(not service_ok(SERVICE_URL),
                    reason='service is unreachable')
def test_wfs3_ldproxy():
    w = WebFeatureService(SERVICE_URL, version='3.0')

    assert w.url == 'https://www.ldproxy.nrw.de/rest/services/kataster/'
    assert w.version == '3.0'
    assert w.url_query_string == 'f=json'

    conformance = w.conformance()
    assert len(conformance['conformsTo']) == 5
예제 #5
0
from unittest import mock

import pytest
from tests.utils import service_ok

from owslib.wms import WebMapService
from owslib.util import ServiceException
from owslib.util import ResponseWrapper


SERVICE_URL = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r-t.cgi'
NCWMS2_URL = "http://wms.stccmop.org:8080/ncWMS2/wms"


@pytest.mark.online
@pytest.mark.skipif(not service_ok(SERVICE_URL),
                    reason="WMS service is unreachable")
def test_wms_getmap_111():
    """MESONET GetMap 1.1.1"""
    wms = WebMapService(SERVICE_URL, version='1.1.1')
    assert wms.request == '{}?service=WMS&request=GetCapabilities&version=1.1.1'.format(SERVICE_URL)
    rsp = wms.getmap(
        layers=['nexrad_base_reflect'],
        styles=['default'],
        srs='EPSG:4326',
        bbox=(-126, 24, -66, 50),
        size=(250, 250),
        format='image/jpeg',
        transparent=True)
    import owslib.util
    assert type(rsp) is ResponseWrapper
예제 #6
0
from tests.utils import scratch_file
from tests.utils import service_ok

from owslib.wmts import WebMapTileService

import pytest

SERVICE_URL = 'http://map1c.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi'


@pytest.mark.online
@pytest.mark.skipif(not service_ok(SERVICE_URL),
                    reason="WMTS service is unreachable")
@pytest.mark.skip(reason="WMTS service not responding correctly")
def test_wmts():
    # Find out what a WMTS has to offer. Service metadata:
    wmts = WebMapTileService(SERVICE_URL)
    assert wmts.identification.type == 'OGC WMTS'
    assert wmts.identification.version == '1.0.0'
    assert wmts.identification.title == 'NASA Global Imagery Browse Services for EOSDIS'
    bytearray(wmts.identification.abstract, 'utf-8')
    bytearray(b'Near real time imagery from multiple NASA instruments')
    assert wmts.identification.keywords == ['World', 'Global']
    # Service Provider:
    assert wmts.provider.name == 'National Aeronautics and Space Administration'
    assert wmts.provider.url == 'https://earthdata.nasa.gov/'
    # Available Layers:
    assert len(wmts.contents.keys()) > 0
    assert sorted(list(wmts.contents))[0] == 'AIRS_CO_Total_Column_Day'
    # Fetch a tile (using some defaults):
    tile = wmts.gettile(layer='MODIS_Terra_CorrectedReflectance_TrueColor',
예제 #7
0
from tests.utils import resource_file
import owslib
from owslib.csw import CatalogueServiceWeb
from owslib.wms import WebMapService
from owslib.wcs import WebCoverageService
from owslib.wfs import WebFeatureService
from owslib.util import OrderedDict

# TODO, we should run all these from local XML documents (as per the WMS and WFS services)
# CSW_SERVICE_URL = 'http://data.nodc.noaa.gov/geoportal/csw'
CSW_SERVICE_URL = 'https://demo.pycsw.org/cite/csw'
WCS_SERVICE_URL = 'http://thredds.ucar.edu/thredds/wcs/grib/NCEP/NAM/CONUS_80km/best'


@pytest.mark.online
@pytest.mark.skipif(not service_ok(CSW_SERVICE_URL),
                    reason='service is unreachable')
def test_ows_interfaces_csw():
    service = CatalogueServiceWeb(CSW_SERVICE_URL)
    # Check each service instance conforms to OWSLib interface
    service.alias = 'CSW'
    isinstance(service, owslib.catalogue.csw2.CatalogueServiceWeb)
    # URL attribute
    assert service.url == CSW_SERVICE_URL
    # version attribute
    assert service.version == '2.0.2'
    # Identification object
    assert hasattr(service, 'identification')
    # Check all ServiceIdentification attributes
    assert service.identification.type == 'CSW'
    for attribute in [
예제 #8
0
import pytest
from tests.utils import service_ok

from owslib.wms import WebMapService
from owslib.util import ServiceException
from owslib.util import ResponseWrapper

SERVICE_URL = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r-t.cgi'
NCWMS2_URL = "http://wms.stccmop.org:8080/ncWMS2/wms"


@pytest.mark.online
@pytest.mark.skipif(not service_ok(SERVICE_URL),
                    reason="WMS service is unreachable")
def test_wms_getmap_111():
    """MESONET GetMap 1.1.1"""
    wms = WebMapService(SERVICE_URL, version='1.1.1')
    assert wms.request == '{}?service=WMS&request=GetCapabilities&version=1.1.1'.format(
        SERVICE_URL)
    rsp = wms.getmap(layers=['nexrad_base_reflect'],
                     styles=['default'],
                     srs='EPSG:4326',
                     bbox=(-126, 24, -66, 50),
                     size=(250, 250),
                     format='image/jpeg',
                     transparent=True)
    import owslib.util
    assert type(rsp) is ResponseWrapper


@pytest.mark.online
예제 #9
0
# SOS version 2.0 tests on http://www.bom.gov.au/waterdata/services

from owslib.sos import SensorObservationService

from tests.utils import service_ok
import pytest

SERVICE_URL = 'http://www.bom.gov.au/waterdata/services'


@pytest.mark.online
@pytest.mark.skip('service responds with an exception (#496)')
@pytest.mark.skipif(not service_ok(SERVICE_URL + "?service=SOS&request=GetCapabilities"),
                    reason="SOS service is unreachable")
def test_sos_20_bom_gov_au():
    # Setup
    service = SensorObservationService(SERVICE_URL, version='2.0.0')
    id = service.identification
    # Check basic service metadata
    assert id.service == 'SOS'
    assert id.title == 'KISTERS KiWIS SOS2'
    assert id.keywords == []
    assert service.provider.name == 'Provider Name'
    assert service.provider.contact.name == 'Name'
    assert service.provider.contact.position is None
    assert len(service.operations) == 5
    assert service.get_operation_by_name('GetObservation').methods[0]['url'] == \
        'http://bom.gov.au/waterdata/services?datasource=0'
    response = service.get_observation(
        featureOfInterest='http://bom.gov.au/waterdata/services/stations/181.1',
        offerings=['http://bom.gov.au/waterdata/services/tstypes/Pat4_PC_1'],
예제 #10
0
class TestOnline(object):
    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WFS_SERVICE_URL),
                        reason="WFS service is unreachable")
    @pytest.mark.parametrize("wfs_version", ["1.1.0", "2.0.0"])
    def test_wfs_remotemd_parse_single(self, wfs_version):
        """Test the remote metadata parsing for WFS.

        Tests parsing the remote metadata for a single layer.

        Test whether the method is available and returns remote metadata.

        """
        wfs = WebFeatureService(url=WFS_SERVICE_URL,
                                version=wfs_version,
                                parse_remote_metadata=False)

        assert 'gw_meetnetten:meetnetten' in wfs.contents
        layer = wfs.contents['gw_meetnetten:meetnetten']
        layer.parse_remote_metadata()

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) > 0

        for m in mdrecords:
            assert type(m) is owslib.iso.MD_Metadata

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WFS_SERVICE_URL),
                        reason="WFS service is unreachable")
    @pytest.mark.parametrize("wfs_version", ["1.1.0", "2.0.0"])
    def test_wfs_remotemd_parse_all(self, wfs_version):
        """Test the remote metadata parsing for WFS.

        Tests parsing the remote metadata for all layers.

        Test whether the method is available and returns remote metadata.

        """
        wfs = WebFeatureService(url=WFS_SERVICE_URL,
                                version=wfs_version,
                                parse_remote_metadata=True)

        assert 'gw_meetnetten:meetnetten' in wfs.contents
        layer = wfs.contents['gw_meetnetten:meetnetten']

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) > 0

        for m in mdrecords:
            assert type(m) is owslib.iso.MD_Metadata

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WFS_SERVICE_URL),
                        reason="WFS service is unreachable")
    @pytest.mark.parametrize("wfs_version", ["1.1.0", "2.0.0"])
    def test_wfs_remotemd_parse_none(self, wfs_version):
        """Test the remote metadata parsing for WFS.

        Tests the case when no remote metadata is parsed.

        Test whether no remote metadata is returned.

        """
        wfs = WebFeatureService(url=WFS_SERVICE_URL,
                                version=wfs_version,
                                parse_remote_metadata=False)

        assert 'gw_meetnetten:meetnetten' in wfs.contents
        layer = wfs.contents['gw_meetnetten:meetnetten']

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) == 0

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WFS_SERVICE_URL),
                        reason="WFS service is unreachable")
    @pytest.mark.parametrize("wfs_version", ["1.0.0"])
    def test_wfs_noremotemd_parse_single(self, wfs_version):
        """Test the remote metadata parsing for WFS.

        Tests parsing the remote metadata for a single layer.

        Test whether the method is available and returns no remote metadata
        if no MetadataURLs are available in the GetCapabilities.

        """
        wfs = WebFeatureService(url=WFS_SERVICE_URL,
                                version=wfs_version,
                                parse_remote_metadata=False)

        assert 'gw_meetnetten:meetnetten' in wfs.contents
        layer = wfs.contents['gw_meetnetten:meetnetten']
        layer.parse_remote_metadata()

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) == 0

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WFS_SERVICE_URL),
                        reason="WFS service is unreachable")
    @pytest.mark.parametrize("wfs_version", ["1.0.0"])
    def test_wfs_noremotemd_parse_all(self, wfs_version):
        """Test the remote metadata parsing for WFS.

        Tests parsing the remote metadata for all layers.

        Test whether the method is available and returns no remote
        metadata if no MetadataURLs are available in the GetCapabilities.

        """
        wfs = WebFeatureService(url=WFS_SERVICE_URL,
                                version=wfs_version,
                                parse_remote_metadata=True)

        assert 'gw_meetnetten:meetnetten' in wfs.contents
        layer = wfs.contents['gw_meetnetten:meetnetten']

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) == 0

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WFS_SERVICE_URL),
                        reason="WFS service is unreachable")
    @pytest.mark.parametrize("wfs_version", ["1.0.0"])
    def test_wfs_noremotemd_parse_none(self, wfs_version):
        """Test the remote metadata parsing for WFS.

        Tests the case when no remote metadata is parsed.

        Test whether no remote metadata is returned.

        """
        wfs = WebFeatureService(url=WFS_SERVICE_URL,
                                version=wfs_version,
                                parse_remote_metadata=False)

        assert 'gw_meetnetten:meetnetten' in wfs.contents
        layer = wfs.contents['gw_meetnetten:meetnetten']

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) == 0

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WMS_SERVICE_URL),
                        reason="WMS service is unreachable")
    @pytest.mark.parametrize("wms_version", ["1.3.0"])
    def test_wms_remotemd_parse_single(self, wms_version):
        """Test the remote metadata parsing for WMS.

        Tests parsing the remote metadata for a single layer.

        Test whether the method is available and returns remote metadata.

        """
        wms = WebMapService(url=WMS_SERVICE_URL,
                            version=wms_version,
                            parse_remote_metadata=False)

        assert 'meetnetten' in wms.contents
        layer = wms.contents['meetnetten']
        layer.parse_remote_metadata()

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) > 0

        for m in mdrecords:
            assert type(m) is owslib.iso.MD_Metadata

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WMS_SERVICE_URL),
                        reason="WMS service is unreachable")
    @pytest.mark.parametrize("wms_version", ["1.3.0"])
    def test_wms_remotemd_parse_all(self, wms_version):
        """Test the remote metadata parsing for WMS.

        Tests parsing the remote metadata for all layers.

        Test whether the method is available and returns remote metadata.

        """
        wms = WebMapService(url=WMS_SERVICE_URL,
                            version=wms_version,
                            parse_remote_metadata=True)

        assert 'meetnetten' in wms.contents
        layer = wms.contents['meetnetten']

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) > 0

        for m in mdrecords:
            assert type(m) is owslib.iso.MD_Metadata

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WMS_SERVICE_URL),
                        reason="WMS service is unreachable")
    @pytest.mark.parametrize("wms_version", ["1.3.0"])
    def test_wms_remotemd_parse_none(self, wms_version):
        """Test the remote metadata parsing for WMS.

        Tests the case when no remote metadata is parsed.

        Test whether no remote metadata is returned.

        """
        wms = WebMapService(url=WMS_SERVICE_URL,
                            version=wms_version,
                            parse_remote_metadata=False)

        assert 'meetnetten' in wms.contents
        layer = wms.contents['meetnetten']

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) == 0

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WMS_SERVICE_URL),
                        reason="WMS service is unreachable")
    @pytest.mark.parametrize("wms_version", ["1.1.1"])
    def test_wms_noremotemd_parse_single(self, wms_version):
        """Test the remote metadata parsing for WMS.

         Tests parsing the remote metadata for a single layer.

         Test whether the method is available and returns no remote metadata
         if no MetadataURLs are available in the GetCapabilities.

         """
        wms = WebMapService(url=WMS_SERVICE_URL,
                            version=wms_version,
                            parse_remote_metadata=False)

        assert 'meetnetten' in wms.contents
        layer = wms.contents['meetnetten']
        layer.parse_remote_metadata()

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) == 0

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WMS_SERVICE_URL),
                        reason="WMS service is unreachable")
    @pytest.mark.parametrize("wms_version", ["1.1.1"])
    def test_wms_noremotemd_parse_all(self, wms_version):
        """Test the remote metadata parsing for WMS.

        Tests parsing the remote metadata for all layers.

        Test whether the method is available and returns no remote
        metadata if no MetadataURLs are available in the GetCapabilities.

        """
        wms = WebMapService(url=WMS_SERVICE_URL,
                            version=wms_version,
                            parse_remote_metadata=True)

        assert 'meetnetten' in wms.contents
        layer = wms.contents['meetnetten']

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) == 0

    @pytest.mark.online
    @pytest.mark.skipif(not service_ok(WMS_SERVICE_URL),
                        reason="WMS service is unreachable")
    @pytest.mark.parametrize("wms_version", ["1.1.1"])
    def test_wms_noremotemd_parse_none(self, wms_version):
        """Test the remote metadata parsing for WMS.

        Tests the case when no remote metadata is parsed.

        Test whether no remote metadata is returned.

        """
        wms = WebMapService(url=WMS_SERVICE_URL,
                            version=wms_version,
                            parse_remote_metadata=False)

        assert 'meetnetten' in wms.contents
        layer = wms.contents['meetnetten']

        mdrecords = layer.get_metadata()
        assert type(mdrecords) is list
        assert len(mdrecords) == 0
예제 #11
0
def test_wms_getmap():
    assert service_ok(SERVICE_URL)
    # Lastly, test the getcapabilities and getmap methods
    wms = WebMapService(SERVICE_URL, version='1.1.1')