Imports

    >>> from tests.utils import resource_file
    >>> from owslib.sos import SensorObservationService
    >>> from owslib.ows import OperationsMetadata
    >>> from owslib.fes import FilterCapabilities
    >>> from owslib.crs import Crs
    >>> from datetime import datetime


Initialize

    >>> xml = open(resource_file('sos_ndbc_getcapabilities.xml'),'rb').read()
    >>> ndbc = SensorObservationService(None, xml=xml)


GetObservation

    # Send a funky eventTime

    >>> off = ndbc.offerings[1]
    >>> offerings = [off.name]
    >>> responseFormat = off.response_formats[0]
    >>> observedProperties = [off.observed_properties[0]]
    >>> #observedProperties = [ndbc.get_operation_by_name('GetObservation').parameters['observedProperty']['values'][0]]
    >>> eventTime = "This is not a valid eventTime!"
    >>> response = ndbc.get_observation(offerings=offerings, responseFormat=responseFormat, observedProperties=observedProperties, eventTime=eventTime)     #doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ServiceException: 'This is not a valid eventTime!'

    # NDBC only supports one offering and one observedProperty at a time

    >>> off = ndbc.offerings[1]
    >>> offerings = [off.name]
    >>> responseFormat = off.response_formats[0]
    >>> observedProperties = [off.observed_properties[0]]
    >>> #observedProperties = [ndbc.get_operation_by_name('GetObservation').parameters['observedProperty']['values'][0]]
    >>> eventTime = None

    >>> response = ndbc.get_observation(offerings=offerings, responseFormat=responseFormat, observedProperties=observedProperties, eventTime=eventTime)
    

DescribeSensor

    # Send a funky procedure

    >>> procedure = "foobar"
    >>> outputFormat = ndbc.get_operation_by_name('DescribeSensor').parameters['outputFormat']['values'][0]
    >>> response = ndbc.describe_sensor(procedure=procedure, outputFormat=outputFormat)     #doctest: +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ServiceException: 'foobar'

    # Valid request

    >>> procedure = ndbc.offerings[1].procedures[0]
    >>> outputFormat = ndbc.get_operation_by_name('DescribeSensor').parameters['outputFormat']['values'][0]
    >>> response = ndbc.describe_sensor(procedure=procedure, outputFormat=outputFormat)
