
Imports

    >>> from __future__ import (absolute_import, division, print_function)
    >>> from owslib.wms import WebMapService
    >>> from tests.utils import resource_file
    >>> from operator import itemgetter

Fake a request to a WMS Server using saved doc from 
http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r-t.cgi?

    >>> xml = open(resource_file('wms_mesonet-caps.xml'), 'rb').read()
    >>> wms = WebMapService('url', version='1.1.1', xml=xml)
    
Test capabilities
-----------------

    >>> wms.identification.type
    'OGC:WMS'
    >>> wms.identification.version
    '1.1.1'
    >>> wms.identification.title
    'IEM WMS Service'
    >>> wms.identification.abstract
    'IEM generated CONUS composite of NWS WSR-88D level III base reflectivity.'
    >>> wms.identification.keywords
    []
    >>> wms.identification.accessconstraints
    'None'

Test available content layers

    >>> sorted(wms.contents.keys())
    ['nexrad-n0r-wmst', 'nexrad_base_reflect', 'time_idx']

    >>> sorted([wms[layer].id for layer in wms.contents])
    ['nexrad-n0r-wmst', 'nexrad_base_reflect', 'time_idx']

 
Test single item accessor
    
    >>> wms['time_idx'].title
    'NEXRAD BASE REFLECT'

    >>> wms['time_idx'].keywords
    []
    
    >>> wms['time_idx'].boundingBox
    (-126.0, 24.0, -66.0, 50.0, 'EPSG:4326')

    >>> wms['time_idx'].boundingBoxWGS84
    (-126.0, 24.0, -66.0, 50.0)
    
    >>> sorted(wms['time_idx'].crsOptions)
    ['EPSG:102100', 'EPSG:3857', 'EPSG:4326', 'EPSG:900913']

    >>> wms['time_idx'].styles
    {}

    >>> wms['time_idx'].timepositions
    ['1995-01-01/2013-12-31/PT5M']

    >>> wms['time_idx'].defaulttimeposition
    '2006-06-23T03:10:00Z'

    >>> wms['nexrad_base_reflect'].timepositions

    >>> wms['nexrad_base_reflect'].defaulttimeposition

Expect a KeyError for invalid names

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

Test operations

    >>> [op.name for op in wms.operations]
    ['GetCapabilities', 'GetMap', 'GetFeatureInfo', 'DescribeLayer', 'GetLegendGraphic', 'GetStyles']

    >>> x = sorted(wms.getOperationByName('GetMap').methods, key=itemgetter('type'))
    >>> x == [{'type': 'Get', 'url': 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r-t.cgi?'}, {'type': 'Post', 'url': 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r-t.cgi?'}]
    True

    >>> wms.getOperationByName('GetMap').formatOptions
    ['image/png', 'image/jpeg', 'image/gif', 'image/png; mode=8bit', 'application/x-pdf', 'image/svg+xml', 'image/tiff']

Test exceptions

    >>> wms.exceptions
    ['application/vnd.ogc.se_xml', 'application/vnd.ogc.se_inimage', 'application/vnd.ogc.se_blank']
