
Imports

    >>> from tests.utils import cast_tuple_int_list, resource_file
    >>> from owslib.wfs import WebFeatureService
    >>> from operator import itemgetter

Fake a request to a WFS Server using saved doc from.

    >>> xml = open(resource_file('mapserver-wfs-cap.xml'), 'rb').read()
    >>> wfs = WebFeatureService('url', version='1.0', xml=xml)

Test capabilities

    >>> wfs.updateSequence is not None
    True

Service Identification:

    >>> wfs.identification.type
    'MapServer WFS'

    >>> wfs.identification.version
    '1.0'

    >>> wfs.identification.title
    'Atlas of the Cryosphere: Southern Hemisphere'

    >>> wfs.identification.abstract
    "The National Snow and Ice Data Center (NSIDC) Atlas of the Cryosphere is a map server that provides data and information pertinent to the frozen regions of Earth, including monthly climatologies of sea ice extent and concentration, snow cover extent, and snow water equivalent, in addition to glacier outlines, ice sheet elevation and accumulation, and more. In order to support polar projections, the Atlas is divided into two separate map servers: one for the Northern Hemisphere and one for the Southern Hemisphere. In addition to providing map images and source data through Open Geospatial Consortium, Inc. (OGC) protocols (WMS, WFS, and WCS), a dynamic web interface for exploring these data is also available at http://nsidc.org/data/atlas. If you have questions, comments or suggestions, please contact NSIDC User Services at +1.303.492.6199 or nsidc@nsidc.org. The development of this map server application was supported by NASA's Earth Observing System (EOS) Program under contract NAS5-03099 and was developed using MapServer, an Open Source development environment for building spatially-enabled internet applications. To cite the Atlas of the Cryosphere: Maurer, J. 2007. Atlas of the Cryosphere. Boulder, Colorado USA: National Snow and Ice Data Center. Digital media. Available at http://nsidc.org/data/atlas/."

    >>> wfs.identification.keywords
    ['\n    Antarctica\n    Cryosphere\n    Earth Science\n    Fronts\n    Glacial Landforms/Processes\n    Glaciers\n    Ice Sheets\n    Oceans\n    Ocean Circulation\n    Ocean Currents\n    Polar\n    Southern Hemisphere\n  ']

    >>> wfs.identification.accessconstraints
    'none'

    >>> wfs.identification.fees
    'none'

Service Provider:

    >>> wfs.provider.name
    'MapServer WFS'

    >>> wfs.provider.url
    'http://nsidc.org'

    #TODO: test contact info:
    #>>> wfs.provider.contact.name


Test available content layers

    >>> sorted(wfs.contents.keys())
    ['antarctic_coastline', 'antarctic_continent', 'antarctic_ice_cores', 'antarctic_ice_shelves_fill', 'antarctic_ice_shelves_outline', 'antarctic_islands', 'antarctic_islands_coastlines', 'antarctic_megadunes', 'antarctic_polar_front', 'antarctic_research_stations', 'antarctica_country_border', 'antarctica_elevation_contours', 'antarctica_islands_coastlines', 'coastlines_excluding_antarctica', 'country_borders_excluding_antarctica', 'glacier_outlines', 'glaciers', 'international_date_line', 'land_excluding_antarctica', 'south_pole_geographic', 'south_pole_geomagnetic', 'south_pole_inaccessibility', 'south_pole_magnetic', 'south_pole_of_cold', 'south_poles_wfs']

    >>> sorted([wfs[layer].title for layer in wfs.contents])
    ['Antarctic Polar Front', 'Antarctic coastline (includes ice shelves)', 'Antarctic continent', 'Antarctic grounding line (excludes ice shelves)', 'Antarctic ice core locations', 'Antarctic ice shelves', 'Antarctic island coastlines', 'Antarctic island coastlines', 'Antarctic islands', 'Antarctic megadunes', 'Antarctic permanent research stations', 'Antarctic suface elevation contours', 'Antarctica border', 'International Date Line', 'South Pole of Cold', 'South Pole of Inaccessibility', 'South Pole, Geographic', 'South Pole, Geomagnetic', 'South Pole, Magnetic', 'South Poles', 'coastlines (excluding Antarctica)', 'countries (excluding Antarctica)', 'glacier outlines', 'glaciers', 'land (excluding Antarctica)']

Test single item accessor

    >>> wfs['glaciers'].title
    'glaciers'

    >>> wfs['glaciers'].boundingBox
    (-11887400000.0, -850889000.0, 557154000.0, 262891000.0, urn:ogc:def:crs:EPSG::3031)

    >>> [x.getcode() for x in wfs['glaciers'].crsOptions]
    ['EPSG:3031']

    >>> wfs['glaciers'].verbOptions
    ['{http://www.opengis.net/wfs}Query']

Expect a KeyError for invalid names

    >>> wfs['utterly bogus'].title
    Traceback (most recent call last):
    ...
    KeyError: 'No content named utterly bogus'

Test operations

    >>> sorted([op.name for op in wfs.operations])
    ['DescribeFeatureType', 'GetCapabilities', 'GetFeature']

    >>> x = sorted(wfs.getOperationByName('GetFeature').methods, key=itemgetter('type'))
    >>> x == [{'type': 'Get', 'url': 'http://nsidc.org/cgi-bin/atlas_south?'}, {'type': 'Post', 'url': 'http://nsidc.org/cgi-bin/atlas_south?'}]
    True

    >>> sorted(wfs.getOperationByName('GetFeature').formatOptions)
    ['{http://www.opengis.net/wfs}GML2']


Test exceptions

    >>> wfs.exceptions
    []

Lastly, test the getcapabilities method

    >>> wfs = WebFeatureService('http://nsidc.org/cgi-bin/atlas_south?', version='1.0')
    >>> xml = wfs.getcapabilities().read()
    >>> xml.find(b'<WFS_Capabilities') > 0
    True
