Skip to content

Commit

Permalink
Fixing 52n sos20 test, adding sos20/waterml2 test, removing broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
kwilcox committed May 24, 2016
1 parent db4730e commit fe093ed
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 91 deletions.
48 changes: 28 additions & 20 deletions tests/doctests/sos_20_52N_demo.txt
Expand Up @@ -2,28 +2,18 @@

>>> from owslib.sos import SensorObservationService
>>> service = SensorObservationService('http://sensorweb.demo.52north.org/52n-sos-webapp/sos/kvp',version='2.0.0')
>>> for content in service.contents:
>>> for content in sorted(service.contents):
... print(content)
...
test1
http://www.52north.org/test/offering/8
http://www.52north.org/test/offering/9
myOfferingXYT
http://www.example.org/offering/http://www.52north.org/test/procedure/9x/observations
http://www.52north.org/test/offering/1
http://www.52north.org/test/offering/2
http://www.52north.org/test/offering/3
http://www.52north.org/test/offering/1
http://www.52north.org/test/offering/6
http://www.52north.org/test/offering/7
http://www.52north.org/test/offering/4
http://www.52north.org/test/offering/5
http://www.example.org/offering/http://www.52north.org/test/procedure/9x4/observations
http://www.52north.org/test/offering/29
asdafagfa
http://www.52north.org/test/offering/19
http://www.52north.org/test/offering/SHUSIV_1
z1
http://www.52north.org/test/offering/22
http://www.52north.org/test/offering/6
http://www.52north.org/test/offering/7
http://www.52north.org/test/offering/8
http://www.52north.org/test/offering/developer

>>> id = service.identification

Expand All @@ -39,12 +29,30 @@ http://www.52north.org/test/offering/22
'52North'

>>> len(service.operations)
13
16

# Check allowed params for get FOI
>>> get_foi=service.get_operation_by_name('GetFeatureOfInterest')
>>> get_foi.parameters['featureOfInterest']['values']
['http://www.52north.org/test/featureOfInterest/1', 'http://www.52north.org/test/featureOfInterest/19', 'http://www.52north.org/test/featureOfInterest/2', 'http://www.52north.org/test/featureOfInterest/3', 'http://www.52north.org/test/featureOfInterest/4', 'http://www.52north.org/test/featureOfInterest/5', 'http://www.52north.org/test/featureOfInterest/6', 'http://www.52north.org/test/featureOfInterest/7', 'http://www.52north.org/test/featureOfInterest/8', 'http://www.52north.org/test/featureOfInterest/9']
>>> try:
... x = unicode('test')
... for x in sorted(get_foi.parameters['featureOfInterest']['values']):
... print(x.encode('utf8'))
... except:
... for x in sorted(get_foi.parameters['featureOfInterest']['values']):
... print(x)
http://www.52north.org/test/featureOfInterest/1
http://www.52north.org/test/featureOfInterest/2
http://www.52north.org/test/featureOfInterest/3
http://www.52north.org/test/featureOfInterest/4
http://www.52north.org/test/featureOfInterest/5
http://www.52north.org/test/featureOfInterest/6
http://www.52north.org/test/featureOfInterest/7
http://www.52north.org/test/featureOfInterest/8
http://www.52north.org/test/featureOfInterest/Heiden
http://www.52north.org/test/featureOfInterest/Münster/FE101
http://www.52north.org/test/featureOfInterest/Portland
http://www.52north.org/test/featureOfInterest/TODO
http://www.52north.org/test/featureOfInterest/world

# Check allowed params for get observation
>>> get_obs=service.get_operation_by_name('GetObservation')
Expand All @@ -54,6 +62,6 @@ get_obs.parameters['responseFormat']['values']

# Get observation call

# Get latest value using O&M reponse format
# Get latest value using O&M reponse format
#'<?xml version="1.0" encoding="UTF-8"?>\n<sos:GetObservationResponse xmlns:sos="http://www.opengis.net/sos/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:om="http://www.opengis.net/om/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sos/2.0 http://schemas.opengis.net/sos/2.0/sosGetObservation.xsd http://www.opengis.net/gml/3.2 http://schemas.opengis.net/gml/3.2.1/gml.xsd http://www.opengis.net/om/2.0 http://schemas.opengis.net/om/2.0/observation.xsd">\n <sos:observationData>\n <om:OM_Observation gml:id="o_729058FD6AAFC4701C83D125175F889F51FD4798">\n <om:type xlink:href="http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement"/>\n <om:phenomenonTime>\n <gml:TimeInstant gml:id="phenomenonTime_2118549">\n <gml:timePosition>2014-07-10T04:31:58.000Z</gml:timePosition>\n </gml:TimeInstant>\n </om:phenomenonTime>\n <om:resultTime xlink:href="#phenomenonTime_2118549"/>\n <om:procedure xlink:href="http://geoviqua.dev.52north.org/procedures/WXT520"/>\n <om:observedProperty xlink:href="http://geoviqua.dev.52north.org/properties/AirTemperature"/>\n <om:featureOfInterest xlink:href="http://geoviqua.dev.52north.org/stations/Vaisala-WXT520" xlink:title="Vaisala_WXT520"/>\n <om:result xmlns:ns="http://www.opengis.net/gml/3.2" uom="degC" xsi:type="ns:MeasureType">17.2</om:result>\n </om:OM_Observation>\n </sos:observationData>\n</sos:GetObservationResponse>'
>>> latest_response = service.get_observation('http://www.opengis.net/om/2.0', ['http://www.52north.org/test/offering/1'], ['http://www.52north.org/test/observableProperty/1'], eventTime='om:phenomenonTime,latest', timeout=120)
70 changes: 0 additions & 70 deletions tests/doctests/sos_20_52n_geoviqua.txt

This file was deleted.

46 changes: 46 additions & 0 deletions tests/doctests/sos_20_bom_gov_au.txt
@@ -0,0 +1,46 @@
# SOS version 2.0 tests on http://www.bom.gov.au/waterdata/services

# Imports
>>> from owslib.sos import SensorObservationService

# Setup
>>> service = SensorObservationService('http://www.bom.gov.au/waterdata/services', version='2.0.0')
>>> id = service.identification

# Check basic service metadata
>>> id.service
'SOS'

>>> id.title
'KISTERS KiWIS SOS2'

>>> id.keywords
[]

>>> service.provider.name
'Provider Name'

>>> service.provider.contact.name
'Name'

>>> service.provider.contact.position

>>> len(service.operations)
5

>>> service.get_operation_by_name('GetObservation').methods[0]['url'] = 'http://www.bom.gov.au/waterdata/services'
>>> 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'],
... observedProperties=['http://bom.gov.au/waterdata/services/parameters/Water Course Discharge'],
... eventTime='om:phenomenonTime,2016-01-01T00:00:00+10/2016-03-05T00:00:00+10')

# Process WaterML Response
>>> from owslib.etree import etree
>>> from owslib.swe.observation.sos200 import SOSGetObservationResponse
>>> from owslib.swe.observation.waterml2 import MeasurementTimeseriesObservation

>>> et = etree.fromstring(response)
>>> parsed_response = SOSGetObservationResponse(et)
>>> assert len(parsed_response.observations) > 0
>>> for o in parsed_response.observations:
... assert isinstance(o, MeasurementTimeseriesObservation)
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[pytest]
addopts = -vs --color=yes --tb=native --ignore=setup.py --doctest-modules --doctest-glob 'tests/**/*.txt' --cov-report term-missing --cov owslib
addopts = -v -rxs -s --color=yes --tb=native --ignore=setup.py --doctest-modules --doctest-glob 'tests/**/*.txt' --cov-report term-missing --cov owslib
norecursedirs = .git docs examples etc cov* *.egg* pytest* .tox
python_files=check_*.py
python_functions=check
Expand Down

0 comments on commit fe093ed

Please sign in to comment.