예제 #1
0
def test_wps_response6():
    # Build WPS object; service has been down for some time so skip caps here
    wps = WebProcessingService('http://rsg.pml.ac.uk/wps/vector.cgi', skip_caps=True)

    # Execute face WPS invocation
    request = open(resource_file('wps_PMLExecuteRequest6.xml'), 'rb').read()
    response = open(resource_file('wps_PMLExecuteResponse6.xml'), 'rb').read()
    execution = wps.execute(None, [], request=request, response=response)

    # Check execution result
    assert execution.status == 'ProcessSucceeded'
    assert execution.url == 'http://rsg.pml.ac.uk/wps/vector.cgi'
    assert execution.statusLocation == \
        'http://rsg.pml.ac.uk/wps/wpsoutputs/pywps-132084838963.xml'
    assert execution.serviceInstance == \
        'http://rsg.pml.ac.uk/wps/vector.cgi?service=WPS&request=GetCapabilities&version=1.0.0'
    assert execution.version == '1.0.0'
    # check single output
    output = execution.processOutputs[0]
    assert output.identifier == 'output'
    assert output.title == 'Name for output vector map'
    assert output.mimeType == 'text/xml'
    assert output.dataType == 'ComplexData'
    assert output.reference is None

    response = output.data[0]
    should_return = '''<ns3:FeatureCollection xmlns:ns3="http://ogr.maptools.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://www.opengis.net/wps/1.0.0" xsi:schemaLocation="http://ogr.maptools.org/ output_0n7ij9D.xsd">\n\t\t\t\t\t  <gml:boundedBy xmlns:gml="http://www.opengis.net/gml">\n\t\t\t\t\t    <gml:Box>\n\t\t\t\t\t      <gml:coord><gml:X>-960123.1421801626</gml:X><gml:Y>4665723.56559387</gml:Y></gml:coord>\n\t\t\t\t\t      <gml:coord><gml:X>-101288.6510608822</gml:X><gml:Y>5108200.011823481</gml:Y></gml:coord>\n\t\t\t\t\t    </gml:Box>\n\t\t\t\t\t  </gml:boundedBy>                         \n\t\t\t\t\t  <gml:featureMember xmlns:gml="http://www.opengis.net/gml">\n\t\t\t\t\t    <ns3:output fid="F0">\n\t\t\t\t\t      <ns3:geometryProperty><gml:LineString><gml:coordinates>-960123.142180162365548,4665723.565593870356679,0 -960123.142180162365548,4665723.565593870356679,0 -960123.142180162598379,4665723.565593870356679,0 -960123.142180162598379,4665723.565593870356679,0 -711230.141176006174646,4710278.48552671354264,0 -711230.141176006174646,4710278.48552671354264,0 -623656.677859728806652,4848552.374973464757204,0 -623656.677859728806652,4848552.374973464757204,0 -410100.337491964863148,4923834.82589447684586,0 -410100.337491964863148,4923834.82589447684586,0 -101288.651060882242746,5108200.011823480948806,0 -101288.651060882242746,5108200.011823480948806,0 -101288.651060882257298,5108200.011823480948806,0 -101288.651060882257298,5108200.011823480948806,0</gml:coordinates></gml:LineString></ns3:geometryProperty>\n\t\t\t\t\t      <ns3:cat>1</ns3:cat>\n\t\t\t\t\t      <ns3:id>1</ns3:id>\n\t\t\t\t\t      <ns3:fcat>0</ns3:fcat>\n\t\t\t\t\t      <ns3:tcat>0</ns3:tcat>\n\t\t\t\t\t      <ns3:sp>0</ns3:sp>\n\t\t\t\t\t      <ns3:cost>1002619.181</ns3:cost>\n\t\t\t\t\t      <ns3:fdist>0</ns3:fdist>\n\t\t\t\t\t      <ns3:tdist>0</ns3:tdist>\n\t\t\t\t\t    </ns3:output>\n\t\t\t\t\t  </gml:featureMember>\n\t\t\t\t\t</ns3:FeatureCollection>'''  # noqa
    assert compare_xml(should_return, response) is True
예제 #2
0
def test_wps_response6():
    # Build WPS object; service has been down for some time so skip caps here
    wps = WebProcessingService('http://rsg.pml.ac.uk/wps/vector.cgi', skip_caps=True)

    # Execute face WPS invocation
    request = open(resource_file('wps_PMLExecuteRequest6.xml'), 'rb').read()
    response = open(resource_file('wps_PMLExecuteResponse6.xml'), 'rb').read()
    execution = wps.execute(None, [], request=request, response=response)

    # Check execution result
    assert execution.status == 'ProcessSucceeded'
    assert execution.url == 'http://rsg.pml.ac.uk/wps/vector.cgi'
    assert execution.statusLocation == \
        'http://rsg.pml.ac.uk/wps/wpsoutputs/pywps-132084838963.xml'
    assert execution.serviceInstance == \
        'http://rsg.pml.ac.uk/wps/vector.cgi?service=WPS&request=GetCapabilities&version=1.0.0'
    assert execution.version == '1.0.0'
    # check single output
    output = execution.processOutputs[0]
    assert output.identifier == 'output'
    assert output.title == 'Name for output vector map'
    assert output.mimeType == 'text/xml'
    assert output.dataType == 'ComplexData'
    assert output.reference is None

    response = output.data[0]
    should_return = '''<ns3:FeatureCollection xmlns:ns3="http://ogr.maptools.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://www.opengis.net/wps/1.0.0" xsi:schemaLocation="http://ogr.maptools.org/ output_0n7ij9D.xsd">\n\t\t\t\t\t  <gml:boundedBy xmlns:gml="http://www.opengis.net/gml">\n\t\t\t\t\t    <gml:Box>\n\t\t\t\t\t      <gml:coord><gml:X>-960123.1421801626</gml:X><gml:Y>4665723.56559387</gml:Y></gml:coord>\n\t\t\t\t\t      <gml:coord><gml:X>-101288.6510608822</gml:X><gml:Y>5108200.011823481</gml:Y></gml:coord>\n\t\t\t\t\t    </gml:Box>\n\t\t\t\t\t  </gml:boundedBy>                         \n\t\t\t\t\t  <gml:featureMember xmlns:gml="http://www.opengis.net/gml">\n\t\t\t\t\t    <ns3:output fid="F0">\n\t\t\t\t\t      <ns3:geometryProperty><gml:LineString><gml:coordinates>-960123.142180162365548,4665723.565593870356679,0 -960123.142180162365548,4665723.565593870356679,0 -960123.142180162598379,4665723.565593870356679,0 -960123.142180162598379,4665723.565593870356679,0 -711230.141176006174646,4710278.48552671354264,0 -711230.141176006174646,4710278.48552671354264,0 -623656.677859728806652,4848552.374973464757204,0 -623656.677859728806652,4848552.374973464757204,0 -410100.337491964863148,4923834.82589447684586,0 -410100.337491964863148,4923834.82589447684586,0 -101288.651060882242746,5108200.011823480948806,0 -101288.651060882242746,5108200.011823480948806,0 -101288.651060882257298,5108200.011823480948806,0 -101288.651060882257298,5108200.011823480948806,0</gml:coordinates></gml:LineString></ns3:geometryProperty>\n\t\t\t\t\t      <ns3:cat>1</ns3:cat>\n\t\t\t\t\t      <ns3:id>1</ns3:id>\n\t\t\t\t\t      <ns3:fcat>0</ns3:fcat>\n\t\t\t\t\t      <ns3:tcat>0</ns3:tcat>\n\t\t\t\t\t      <ns3:sp>0</ns3:sp>\n\t\t\t\t\t      <ns3:cost>1002619.181</ns3:cost>\n\t\t\t\t\t      <ns3:fdist>0</ns3:fdist>\n\t\t\t\t\t      <ns3:tdist>0</ns3:tdist>\n\t\t\t\t\t    </ns3:output>\n\t\t\t\t\t  </gml:featureMember>\n\t\t\t\t\t</ns3:FeatureCollection>'''  # noqa
    assert compare_xml(should_return, response) is True
예제 #3
0
def wps():
    '''Returns a WPS instance'''
    # Initialize WPS client
    wps = WebProcessingService('http://example.org/wps', skip_caps=True)
    xml = open(resource_file('wps_CEDACapabilities.xml'), 'rb').read()
    wps.getcapabilities(xml=xml)
    return wps
def test_wps_getcapabilities_usgs():
    # Initialize WPS client
    wps = WebProcessingService('http://cida.usgs.gov/gdp/process/WebProcessingService', skip_caps=True)

    # Execute fake invocation of GetCapabilities operation by parsing cached response from USGS service
    xml = open(resource_file('wps_USGSCapabilities.xml'), 'rb').read()
    wps.getcapabilities(xml=xml)

    # Check WPS description
    assert wps.updateSequence is not None
    assert wps.identification.type == 'WPS'
    assert wps.identification.title == 'Geo Data Portal WPS Implementation'
    assert wps.identification.abstract == 'A Geo Data Portal Service based on the 52north implementation of WPS 1.0.0'

    # Check available operations
    operations = [op.name for op in wps.operations]
    assert operations == [
        'GetCapabilities',
        'DescribeProcess',
        'Execute']

    # Check high level process descriptions
    processes = [(p.identifier, p.title) for p in wps.processes]
    assert processes == [
        ('gov.usgs.cida.gdp.wps.algorithm.filemanagement.ReceiveFiles', 'gov.usgs.cida.gdp.wps.algorithm.filemanagement.ReceiveFiles'),  # noqa
        ('gov.usgs.cida.gdp.wps.algorithm.discovery.CalculateWCSCoverageInfo', 'gov.usgs.cida.gdp.wps.algorithm.discovery.CalculateWCSCoverageInfo'),  # noqa
        ('gov.usgs.cida.gdp.wps.algorithm.communication.EmailWhenFinishedAlgorithm', 'gov.usgs.cida.gdp.wps.algorithm.communication.EmailWhenFinishedAlgorithm'),  # noqa
        ('gov.usgs.cida.gdp.wps.algorithm.communication.GeoserverManagementAlgorithm', 'gov.usgs.cida.gdp.wps.algorithm.communication.GeoserverManagementAlgorithm'),  # noqa
        ('gov.usgs.cida.gdp.wps.algorithm.discovery.GetWcsCoverages', 'gov.usgs.cida.gdp.wps.algorithm.discovery.GetWcsCoverages'),  # noqa
        ('gov.usgs.cida.gdp.wps.algorithm.filemanagement.GetWatersGeom', 'gov.usgs.cida.gdp.wps.algorithm.filemanagement.GetWatersGeom'),  # noqa
        ('gov.usgs.cida.gdp.wps.algorithm.discovery.ListOpendapGrids', 'gov.usgs.cida.gdp.wps.algorithm.discovery.ListOpendapGrids'),  # noqa
        ('gov.usgs.cida.gdp.wps.algorithm.filemanagement.CreateNewShapefileDataStore', 'gov.usgs.cida.gdp.wps.algorithm.filemanagement.CreateNewShapefileDataStore'),  # noqa
        ('gov.usgs.cida.gdp.wps.algorithm.discovery.GetGridTimeRange', 'gov.usgs.cida.gdp.wps.algorithm.discovery.GetGridTimeRange'),  # noqa
        ]
def test_single_atomxml_coding():
    atom1 = open(
        resource_file(os.path.join('owc_atom_examples', 'wms_meris.xml')),
        'rb').read()
    owc = OwcContext.from_atomxml(atom1)
    assert owc is not None
    # logger.debug("s owc title: " + owc.title)
    for res in owc.resources:
        # logger.debug("s res id: " + res.id)
        assert res.title is not None
        assert len(res.offerings) > 0
        for off in res.offerings:
            # logger.debug("s off code: " + off.offering_code)
            assert off.operations is not None
            assert len(off.operations) > 0
        # for lnk in res.preview:
        #     logger.debug(lnk.to_dict())

    jsdata = owc.to_json()
    assert jsdata is not None
    assert len(jsdata) > 10
    re_owc = OwcContext.from_json(jsdata)
    assert re_owc is not None
    for res in re_owc.resources:
        # logger.debug("s res id: " + res.id)
        assert res.title is not None
        assert len(res.offerings) > 0
        for off in res.offerings:
            # logger.debug("s off code: " + off.offering_code)
            assert off.operations is not None
            assert len(off.operations) > 0
        # for lnk in res.preview:
        #     logger.debug(lnk.to_dict())
    assert owc.to_dict() == re_owc.to_dict()
def test_single_atomxml_coding():
    atom1 = open(resource_file(os.path.join('owc_atom_examples', 'wms_meris.xml')), 'rb').read()
    owc = OwcContext.from_atomxml(atom1)
    assert owc is not None
    # logger.debug("s owc title: " + owc.title)
    for res in owc.resources:
        # logger.debug("s res id: " + res.id)
        assert res.title is not None
        assert len(res.offerings) > 0
        for off in res.offerings:
            # logger.debug("s off code: " + off.offering_code)
            assert off.operations is not None
            assert len(off.operations) > 0
        # for lnk in res.preview:
        #     logger.debug(lnk.to_dict())

    jsdata = owc.to_json()
    assert jsdata is not None
    assert len(jsdata) > 10
    re_owc = OwcContext.from_json(jsdata)
    assert re_owc is not None
    for res in re_owc.resources:
        # logger.debug("s res id: " + res.id)
        assert res.title is not None
        assert len(res.offerings) > 0
        for off in res.offerings:
            # logger.debug("s off code: " + off.offering_code)
            assert off.operations is not None
            assert len(off.operations) > 0
        # for lnk in res.preview:
        #     logger.debug(lnk.to_dict())
    assert owc.to_dict() == re_owc.to_dict()
예제 #7
0
def test_wps_describeprocess_bbox():
    # Initialize WPS client
    wps = WebProcessingService('http://localhost:8094/wps', skip_caps=True)
    # Execute fake invocation of DescribeProcess operation by parsing cached response from Emu service
    xml = open(resource_file('wps_bbox_DescribeProcess.xml'), 'rb').read()
    process = wps.describeprocess('bbox', xml=xml)
    # Check process description
    assert process.identifier == 'bbox'
    assert process.title == 'Bounding Box'
    # Check process inputs
    # Example Input:
    #     identifier=bbox, title=Bounding Box, abstract=None, data type=BoundingBoxData
    #     Supported Value: EPSG:4326
    #     Supported Value: EPSG:3035
    #     Default Value: EPSG:4326
    #     minOccurs=1, maxOccurs=1
    for input in process.dataInputs:
        assert input.identifier == 'bbox'
        assert input.dataType == 'BoundingBoxData'
    # Example Output:
    #    identifier=bbox, title=Bounding Box, abstract=None, data type=BoundingBoxData
    #    Supported Value: EPSG:4326
    #    Default Value: EPSG:4326
    #    reference=None, mimeType=None
    # Check process outputs
    for output in process.processOutputs:
        assert output.identifier == 'bbox'
        assert output.dataType == 'BoundingBoxData'
예제 #8
0
    def test_timeseries_multi_station_multi_sensor(self):
        swe = open(resource_file('ioos_swe/SWE-MultiStation-TimeSeries.xml'), 'rb').read()
        data_record = etree.fromstring(swe)
        collection = TimeSeries(data_record).feature

        assert isinstance(collection, StationCollection)
        assert len(collection.elements) == 3
예제 #9
0
def test_wps_literal_data_input_parsing_references():
    xml = open(resource_file('wps_inout_parsing.xml'), 'r').read()
    inputs = etree.fromstring(xml)
    for i, i_elem in enumerate(inputs):
        wps_in = Input(i_elem)
        assert wps_in.identifier == 'input{}'.format(i + 1)
        assert wps_in.dataType == 'string'
예제 #10
0
    def test_o_and_m_get_observation(self):
        data = open(resource_file(os.path.join('ioos_swe', 'OM-GetObservation.xml')), "rb").read()

        d = IoosGetObservation(data)
        assert d.ioos_version       == "1.0"
        assert len(d.observations)  == 1

        ts = d.observations[0]
        assert ts.description.replace("\n", "").replace("       ", "").replace("  -", " -") == "Observations at point station urn:ioos:station:wmo:41001, 150 NM East of Cape HATTERAS. Observations at point station urn:ioos:station:wmo:41002, S HATTERAS - 250 NM East of Charleston, SC"
        assert ts.begin_position                == datetime(2009, 5, 23, 0, tzinfo=pytz.utc)
        assert ts.end_position                  == datetime(2009, 5, 23, 2, tzinfo=pytz.utc)
        assert sorted(ts.procedures)            == sorted(["urn:ioos:station:wmo:41001", "urn:ioos:station:wmo:41002"])
        assert sorted(ts.observedProperties)    == sorted([ "http://mmisw.org/ont/cf/parameter/air_temperature",
                                                            "http://mmisw.org/ont/cf/parameter/sea_water_temperature",
                                                            "http://mmisw.org/ont/cf/parameter/wind_direction",
                                                            "http://mmisw.org/ont/cf/parameter/wind_speed",
                                                            "http://mmisw.org/ont/ioos/parameter/dissolved_oxygen"
                                                            ])
        assert ts.feature_type          == "timeSeries"

        assert ts.bbox_srs.getcode()    == "EPSG:4326"
        assert ts.bbox.equals(box(-75.42, 32.38, -72.73, 34.7))

        assert ts.location["urn:ioos:station:wmo:41001"].equals(Point(-72.73, 34.7))
        assert ts.location["urn:ioos:station:wmo:41002"].equals(Point(-75.415, 32.382))
예제 #11
0
def test_ows_interfaces_wms():
    wmsxml = open(resource_file('wms_JPLCapabilities.xml'), 'rb').read()
    service = WebMapService('url', version='1.1.1', xml=wmsxml)
    # Check each service instance conforms to OWSLib interface
    service.alias = 'WMS'
    isinstance(service, owslib.map.wms111.WebMapService_1_1_1)
    # URL attribute
    assert service.url == 'url'
    # version attribute
    assert service.version == '1.1.1'
    # Identification object
    assert hasattr(service, 'identification')
    # Check all ServiceIdentification attributes
    assert service.identification.type == 'OGC:WMS'
    for attribute in ['type', 'version', 'title', 'abstract', 'keywords', 'accessconstraints', 'fees']:
        assert hasattr(service.identification, attribute)
    # Check all ServiceProvider attributes
    for attribute in ['name', 'url', 'contact']:
        assert hasattr(service.provider, attribute)
    # Check all operations implement IOperationMetadata
    for op in service.operations:
        for attribute in ['name', 'formatOptions', 'methods']:
            assert hasattr(op, attribute)
    # Check all contents implement IContentMetadata as a dictionary
    isinstance(service.contents, OrderedDict)
    # Check any item (WCS coverage, WMS layer etc) from the contents of each service
    # Check it conforms to IContentMetadata interface
    # get random item from contents dictionary -has to be a nicer way to do this!
    content = service.contents[list(service.contents.keys())[0]]
    for attribute in ['id', 'title', 'boundingBox', 'boundingBoxWGS84', 'crsOptions', 'styles', 'timepositions']:
        assert hasattr(content, attribute)
예제 #12
0
    def test_timeseries_single_station_single_sensor(self):
        swe = open(
            resource_file(
                'ioos_swe/SWE-SingleStation-SingleProperty-TimeSeries.xml')
        ).read()
        data_record = etree.fromstring(swe)
        station = TimeSeries(data_record).feature

        assert isinstance(station, Station)

        assert station.uid == "urn:ioos:station:wmo:41001"
        assert station.name == "wmo_41001"
        assert station.location.x == -75.415
        assert station.location.y == 32.382
        assert station.location.z == 0.5

        assert sorted(
            map(lambda x: x.time.strftime("%Y-%m-%dT%H:%M:%SZ"),
                station.elements)) == sorted([
                    "2009-05-23T00:00:00Z", "2009-05-23T01:00:00Z",
                    "2009-05-23T02:00:00Z"
                ])

        first_members = station.elements[0].members
        assert sorted(map(lambda x: x['value'],
                          first_members)) == sorted([2.0, 15.4, 280])
        assert sorted(map(lambda x: x['standard'], first_members)) == sorted([
            "http://mmisw.org/ont/cf/parameter/air_temperature",
            "http://mmisw.org/ont/cf/parameter/wind_to_direction",
            "http://mmisw.org/ont/cf/parameter/wind_speed"
        ])
예제 #13
0
    def test_timeseries_profile_single_station(self):
        swe = open(
            resource_file(
                'ioos_swe/SWE-SingleStation-TimeSeriesProfile_QC.xml')).read()
        data_record = etree.fromstring(swe)
        station = TimeSeriesProfile(data_record).feature

        assert isinstance(station, StationProfile)

        assert station.uid == "urn:ioos:station:wmo:41001"
        assert station.name == "wmo_41001"
        assert station.location.x == -75.415
        assert station.location.y == 32.382
        assert station.location.z == 0.5

        # should have three profiles
        assert len(station.elements) == 3
        station.calculate_bounds()

        # should all be at the same point
        bounds = station.get_bbox()
        assert isinstance(bounds, Point)
        assert bounds.x == -75.415
        assert bounds.y == 32.382

        # time
        time_range = station.get_time_range()
        assert time_range[0].strftime(
            "%Y-%m-%dT%H:%M:%SZ") == "2009-05-23T00:00:00Z"
        assert time_range[-1].strftime(
            "%Y-%m-%dT%H:%M:%SZ") == "2009-05-23T02:00:00Z"

        # depth bounds
        depth_range = station.get_depth_range()
        assert depth_range[0] == -39.5
        assert depth_range[-1] == -4.5

        # spot check values
        profile = station.elements[0]

        assert profile.time.strftime(
            "%Y-%m-%dT%H:%M:%SZ") == "2009-05-23T00:00:00Z"
        assert len(profile.elements) == 4
        assert [e.location.z
                for e in profile.elements] == [-39.5, -19.5, -9.5, -4.5]

        assert len(profile.elements[0].members) == 2
        assert [m['name'] for m in profile.elements[0].members
                ] == ['direction_of_sea_water_velocity', 'sea_water_speed']
        assert [m['value']
                for m in profile.elements[0].members] == [352.0, 9.6]

        sensor = station.sensors['wmo_41001_sensor1']
        assert 'sensor_orientation' in sensor
        assert sensor['sensor_orientation']['X'][
            'name'] == 'platform_pitch_angle'
        assert sensor['sensor_orientation']['Y'][
            'name'] == 'platform_roll_angle'
        assert sensor['sensor_orientation']['Z'][
            'name'] == 'platform_orientation'
def test_wps_describeprocess_ceda():
    # Initialize WPS client
    wps = WebProcessingService('http://ceda-wps2.badc.rl.ac.uk/wps',
                               skip_caps=True)
    # Execute fake invocation of DescribeProcess operation by parsing cached response from CEDA service
    xml = open(resource_file('wps_CEDADescribeProcess.xml'), 'rb').read()
    process = wps.describeprocess('DoubleIt', xml=xml)
    # Check process description
    assert process.identifier == 'DoubleIt'
    assert process.title == 'Doubles the input number and returns value'
    assert process.abstract == 'This is test process used to demonstrate how the WPS and the WPS User Interface work. The process accepts an integer or floating point number and returns some XML containing the input number double.'  # NOQA
    # Check process properties
    assert process.statusSupported is False
    assert process.storeSupported is True
    # Check process inputs
    # Example Input:
    #   identifier=NumberToDouble, title=NumberToDouble, abstract=NumberToDouble, data type=LiteralData
    #   Any value allowed
    #   Default Value: None
    #   minOccurs=1, maxOccurs=-1
    for input in process.dataInputs:
        assert input.identifier == 'NumberToDouble'
        assert input.dataType == 'LiteralData'
    # Example Output:
    #   identifier=OutputXML, title=OutputXML, abstract=OutputXML, data type=ComplexData
    #   Supported Value: mimeType=text/XML, encoding=UTF-8, schema=NONE
    #   Default Value: None
    #   reference=None, mimeType=None
    # Check process outputs
    for output in process.processOutputs:
        assert output.identifier == 'OutputXML'
        assert output.dataType == 'ComplexData'
def test_wps_getcapabilities_52n():
    # Initialize WPS client
    wps = WebProcessingService(
        'http://geoprocessing.demo.52north.org:8080/52n-wps-webapp-3.3.1/WebProcessingService',
        skip_caps=True)

    # Execute fake invocation of GetCapabilities operation by parsing cached response from 52North service
    xml = open(resource_file('wps_52nCapabilities.xml'), 'rb').read()
    wps.getcapabilities(xml=xml)

    # Check WPS description
    assert wps.identification.type == 'WPS'

    # Check available operations
    operations = [op.name for op in wps.operations]
    assert operations == [
        'GetCapabilities',
        'DescribeProcess',
        'Execute']

    # Check high level process descriptions
    processes = [(p.identifier, p.title) for p in wps.processes]
    assert processes == [
        ('org.n52.wps.server.algorithm.test.MultiReferenceInputAlgorithm', 'for testing multiple inputs by reference'),
        ('org.n52.wps.server.algorithm.test.EchoProcess', 'Echo process'),
        ('org.n52.wps.server.algorithm.test.MultiReferenceBinaryInputAlgorithm', 'for testing multiple binary inputs by reference'),  # noqa
        ('org.n52.wps.server.algorithm.test.LongRunningDummyTestClass', 'org.n52.wps.server.algorithm.test.LongRunningDummyTestClass'),  # noqa
        ('org.n52.wps.server.algorithm.JTSConvexHullAlgorithm', 'org.n52.wps.server.algorithm.JTSConvexHullAlgorithm'),
        ('org.n52.wps.server.algorithm.test.MultipleComplexInAndOutputsDummyTestClass', 'org.n52.wps.server.algorithm.test.MultipleComplexInAndOutputsDummyTestClass'),  # noqa
        ('org.n52.wps.server.algorithm.test.DummyTestClass', 'org.n52.wps.server.algorithm.test.DummyTestClass')]
예제 #16
0
def test_wps_execute_invalid_request():
    # Initialize WPS client
    wps = WebProcessingService('http://cida.usgs.gov/gdp/process/WebProcessingService')

    # Submit fake invocation of Execute operation using cached HTTP request and response
    request = open(resource_file('wps_USGSExecuteInvalidRequest.xml'), 'rb').read()
    response = open(resource_file('wps_USGSExecuteInvalidRequestResponse.xml'), 'rb').read()
    execution = wps.execute(None, [], request=request, response=response)

    assert execution.isComplete() is True

    # Display errors
    ex = execution.errors[0]
    assert ex.code is None
    assert ex.locator is None
    assert ex.text == 'Attribute null not found in feature collection'
예제 #17
0
def test_wps_request3():
    # Supply process input argument
    wfsUrl = "http://igsarm-cida-gdp2.er.usgs.gov:8082/geoserver/wfs"
    query = WFSQuery("sample:CONUS_States",
                     propertyNames=['the_geom', "STATE"],
                     filters=["CONUS_States.508", "CONUS_States.469"])
    featureCollection = WFSFeatureCollection(wfsUrl, query)
    processid = 'gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm'
    inputs = [
        ("FEATURE_ATTRIBUTE_NAME", "STATE"),
        ("DATASET_URI",
         "dods://igsarm-cida-thredds1.er.usgs.gov:8080/thredds/dodsC/dcp/conus_grid.w_meta.ncml"
         ), ("DATASET_ID", "ccsm3_a1b_tmax"), ("DATASET_ID", "ccsm3_a1b_pr"),
        ("DATASET_ID", "ccsm3_a1fi_tmax"),
        ("TIME_START", "1960-01-01T00:00:00.000Z"),
        ("TIME_END", "1960-12-31T00:00:00.000Z"),
        ("REQUIRE_FULL_COVERAGE", "true"), ("DELIMITER", "COMMA"),
        ("STATISTICS", "MEAN"), ("STATISTICS", "MINIMUM"),
        ("STATISTICS", "MAXIMUM"), ("STATISTICS", "WEIGHT_SUM"),
        ("STATISTICS", "VARIANCE"), ("STATISTICS", "STD_DEV"),
        ("STATISTICS", "COUNT"), ("GROUP_BY", "STATISTIC"),
        ("SUMMARIZE_TIMESTEP", "true"),
        ("SUMMARIZE_FEATURE_ATTRIBUTE", "true"),
        ("FEATURE_COLLECTION", featureCollection)
    ]
    output = "OUTPUT"

    # build XML request for WPS process execution
    execution = WPSExecution()
    requestElement = execution.buildRequest(processid, inputs, output=output)
    request = etree.tostring(requestElement)

    # Compare to cached XML request
    _request = open(resource_file('wps_USGSExecuteRequest2.xml'), 'rb').read()
    assert compare_xml(request, _request) is True
예제 #18
0
def test_wps_request3():
    # Supply process input arguments
    polygon = [(-102.8184, 39.5273), (-102.8184, 37.418), (-101.2363, 37.418),
               (-101.2363, 39.5273), (-102.8184, 39.5273)]
    featureCollection = GMLMultiPolygonFeatureCollection([polygon])
    processid = 'gov.usgs.cida.gdp.wps.algorithm.FeatureWeightedGridStatisticsAlgorithm'
    inputs = [("FEATURE_ATTRIBUTE_NAME", "the_geom"),
              ("DATASET_URI", "dods://igsarm-cida-thredds1.er.usgs.gov:8080/thredds/dodsC/dcp/conus_grid.w_meta.ncml"),
              ("DATASET_ID", "ccsm3_a1b_tmax"),
              ("TIME_START", "1960-01-01T00:00:00.000Z"),
              ("TIME_END", "1960-12-31T00:00:00.000Z"),
              ("REQUIRE_FULL_COVERAGE", "true"),
              ("DELIMITER", "COMMA"),
              ("STATISTICS", "MEAN"),
              ("STATISTICS", "MINIMUM"),
              ("STATISTICS", "MAXIMUM"),
              ("STATISTICS", "WEIGHT_SUM"),
              ("STATISTICS", "VARIANCE"),
              ("STATISTICS", "STD_DEV"),
              ("STATISTICS", "COUNT"),
              ("GROUP_BY", "STATISTIC"),
              ("SUMMARIZE_TIMESTEP", "false"),
              ("SUMMARIZE_FEATURE_ATTRIBUTE", "false"),
              ("FEATURE_COLLECTION", featureCollection)]
    output = "OUTPUT"
    # build XML request for WPS process execution
    execution = WPSExecution()
    requestElement = execution.buildRequest(processid, inputs, output=output)
    request = etree.tostring(requestElement)
    # Compare to cached XML request
    _request = open(resource_file('wps_USGSExecuteRequest3.xml'), 'rb').read()
    assert compare_xml(request, _request) is True
예제 #19
0
def test_wps_response_with_lineage():
    execution = WPSExecution()
    xml = open(resource_file('wps_HummingbirdExecuteResponse1.xml'),
               'rb').read()
    execution.checkStatus(response=xml)
    assert execution.isSucceded()
    assert execution.creationTime == '2018-05-08T14:00:54Z'
    # check lineage input with literal data
    inp = execution.dataInputs[0]
    assert inp.identifier == 'test'
    assert inp.title == 'Select the test you want to run.'
    assert inp.abstract == 'CF-1.6=Climate and Forecast Conventions (CF)'
    assert inp.data[0] == 'CF-1.6'
    # check lineage input with reference
    inp = execution.dataInputs[1]
    assert inp.identifier == 'dataset'
    assert inp.title == 'Upload your NetCDF file here'
    assert inp.abstract == 'or enter a URL pointing to a NetCDF file.'
    assert inp.reference.startswith('https://www.esrl.noaa.gov/')
    # check output with reference
    outp = execution.processOutputs[0]
    assert outp.identifier == 'output'
    assert outp.title == 'Test Report'
    assert outp.abstract == 'Compliance checker test report.'
    assert outp.reference.startswith('http://localhost:8090/wpsoutputs')
예제 #20
0
    def test_timeseries_multiple_sensor_data_choice(self):
        swe = open(resource_file('swe_timeseries_multiple_sensor.xml'), "rU").read()
        ios = IoosSwe(swe)

        # The BBOX defined in GML
        assert list(ios.observations['TimeSeries_1'].bbox.exterior.coords)[0] == (-78.5, 32.5)

        # featureOfInterest 
        assert ios.observations['TimeSeries_1'].feature_type == 'timeSeries'
        # Location defined within featureOfInterest
        assert ios.observations['TimeSeries_1'].feature.geo.x == -78.5
        assert ios.observations['TimeSeries_1'].feature.geo.y == 32.5

        data = ios.observations['TimeSeries_1'].feature.data
        data.calculate_bounds()

        # Depth range
        assert data.depth_range[0] == -4
        assert data.depth_range[-1] == 10

        # Time range
        assert data.time_range[0] == datetime(2009,05,23, tzinfo=pytz.utc)
        assert data.time_range[-1] == datetime(2009,05,23,2, tzinfo=pytz.utc)

        # Bbox is one point for this test, since it is a single point
        assert data.bbox.x == -78.5
        assert data.bbox.y == 32.5
def test_wps_describeprocess_ceda():
    # Initialize WPS client
    wps = WebProcessingService('http://ceda-wps2.badc.rl.ac.uk/wps', skip_caps=True)
    # Execute fake invocation of DescribeProcess operation by parsing cached response from CEDA service
    xml = open(resource_file('wps_CEDADescribeProcess.xml'), 'rb').read()
    process = wps.describeprocess('Doubleit', xml=xml)
    # Check process description
    assert process.identifier == 'DoubleIt'
    assert process.title == 'Doubles the input number and returns value'
    assert process.abstract == 'This is test process used to demonstrate how the WPS and the WPS User Interface work. The process accepts an integer or floating point number and returns some XML containing the input number double.'  # NOQA
    # Check process properties
    assert process.statusSupported is False
    assert process.storeSupported is True
    # Check process inputs
    # Example Input:
    #   identifier=NumberToDouble, title=NumberToDouble, abstract=NumberToDouble, data type=LiteralData
    #   Any value allowed
    #   Default Value: None
    #   minOccurs=1, maxOccurs=-1
    for input in process.dataInputs:
        assert input.identifier == 'NumberToDouble'
        assert input.dataType == 'LiteralData'
    # Example Output:
    #   identifier=OutputXML, title=OutputXML, abstract=OutputXML, data type=ComplexData
    #   Supported Value: mimeType=text/XML, encoding=UTF-8, schema=NONE
    #   Default Value: None
    #   reference=None, mimeType=None
    # Check process outputs
    for output in process.processOutputs:
        assert output.identifier == 'OutputXML'
        assert output.dataType == 'ComplexData'
예제 #22
0
def test_decode_full_json3():
    jsondata3 = open(resource_file(os.path.join('owc_geojson_examples', 'owc3.geojson')), 'rb').read().decode('utf-8')

    owc3 = OwcContext.from_json(jsondata3)
    assert owc3 is not None
    logger.debug(owc3.to_json())
    re_owc3 = OwcContext.from_json(owc3.to_json())
    assert owc3.to_dict() == re_owc3.to_dict()

    assert owc3.creator_display.pixel_width == 800
    assert owc3.authors[0].email == "*****@*****.**"

    assert len(owc3.keywords) == 5
    assert owc3.resources[0].keywords[0].label == "Informative Layers"

    links_via = [l for l in owc3.context_metadata if
                 l.href == "http://portal.smart-project.info/context/smart-sac.owc.json"]
    assert len(links_via) == 1

    assert owc3.resources[0].temporal_extent.to_dict() == TimeIntervalFormat.from_string(
        "2011-11-04T00:01:23Z/2017-12-05T17:28:56Z").to_dict()

    wms_offering = [of for of in owc3.resources[0].offerings if
                    of.offering_code == "http://www.opengis.net/spec/owc-geojson/1.0/req/wms"]
    assert len(wms_offering) > 0
    assert wms_offering[0].styles[
               0].legend_url == "http://docs.geoserver.org/latest/en/user/_images/line_simpleline1.png"
def test_load_parse():
    jsondata = open(
        resource_file(os.path.join('owc_geojson_examples', 'owc1.geojson')),
        'rb').read().decode('utf-8')
    # logger.debug(jsondata)
    my_dict = decode_json(jsondata)
    logger.debug(str(my_dict))
    assert my_dict is not None
예제 #24
0
    def test_sensor(self):
        data = open(resource_file(os.path.join('ioos_swe','SML-DescribeSensor-Sensor.xml')), "rU").read()
        d = IoosDescribeSensor(data)

        assert d.ioos_version == "1.0"
        assert d.system.name == "urn:ioos:sensor:us.glos:45023:sea_water_temperature"
        assert d.starting     == datetime(2013, 8, 26, 18, 10, tzinfo=pytz.utc)
        assert d.ending       == datetime(2013, 8, 26, 18, 10, tzinfo=pytz.utc)
예제 #25
0
def test_load_bulk():
    js1 = open(resource_file(os.path.join('owc_geojson_examples','from-meta-resource.json')), 'r').read()
    js2 = open(resource_file(os.path.join('owc_geojson_examples','ingest1.owc.geojson')), 'r').read()
    js3 = open(resource_file(os.path.join('owc_geojson_examples','newzealand-overview.json')), 'r').read()
    js4 = open(resource_file(os.path.join('owc_geojson_examples','owc1.geojson')), 'r').read()
    js5 = open(resource_file(os.path.join('owc_geojson_examples','owc2.geojson')), 'r').read()
    js6 = open(resource_file(os.path.join('owc_geojson_examples','owc3.geojson')), 'r').read()
    js7 = open(resource_file(os.path.join('owc_geojson_examples','sac-casestudies.json')), 'r').read()

    feeds = [js1, js2, js3,js4, js5, js6, js7 ]

    for f in feeds:
        logger.debug(f)
        dict_obj = decode_json(f)
        assert dict_obj is not None
        # logger.debug(dict_obj)
        owc = OwcContext.from_dict(dict_obj)
        assert owc is not None
        # logger.debug(OwcContext.from_dict(dict_obj).to_json())
        jsdata = owc.to_json()
        assert jsdata is not None
        assert len(jsdata) > 10
        re_owc = OwcContext.from_json(jsdata)
        assert re_owc is not None
        through = OwcContext.from_json(f)
        assert owc.to_dict() == through.to_dict()
예제 #26
0
    def test_network(self):
        data = open(resource_file(os.path.join('ioos_swe','SML-DescribeSensor-Network.xml')), "rU").read()
        d    = IoosDescribeSensor(data)

        assert d.ioos_version == "1.0"
        assert d.system.name  == "urn:ioos:network:nanoos:all"
        assert d.procedures   == sorted([u'urn:ioos:station:wmo:41001', u'urn:ioos:station:wmo:41002'])
        assert d.starting     == datetime(2008, 4, 28, 8, tzinfo=pytz.utc)
        assert d.ending       == datetime(2012, 12, 27, 19, tzinfo=pytz.utc)
예제 #27
0
def test_wps_describeprocess_emu_all():
    # Initialize WPS client
    wps = WebProcessingService('http://localhost:8094/wps', skip_caps=True)
    # Execute fake invocation of DescribeProcess operation by parsing cached response from
    xml = open(resource_file('wps_EmuDescribeProcess_all.xml'), 'rb').read()
    process = wps.describeprocess('nap', xml=xml)
    processes = wps.describeprocess('all', xml=xml)
    assert isinstance(process, Process)
    assert isinstance(processes, list)
def test_decode_single_json():
    jsondata1 = open(
        resource_file(os.path.join('owc_geojson_examples', 'owc1.geojson')),
        'r').read()

    result = decode_json(jsondata1)
    assert result is not None
    assert result['features'][0]['properties'][
        'date'] == "2013-11-02T15:24:24.446+12:00"
예제 #29
0
def test_verbOptions_wfs_100():
    with open(resource_file("wfs_dov_getcapabilities_100_verbOptions.xml"),
              "rb") as f:
        getcapsin = f.read()
    wfs = WebFeatureService('http://gis.bnhelp.cz/ows/crwfs',
                            xml=getcapsin,
                            version='1.0.0')
    verbOptions = [cm.verbOptions for cm in wfs.contents.values()]
    assert len(verbOptions[0]) == 2
def test_wps_getcapabilities_ceda():
    # Initialize WPS client
    wps = WebProcessingService('http://ceda-wps2.badc.rl.ac.uk/wps', skip_caps=True)

    # Execute fake invocation of GetCapabilities operation by parsing cached response from USGS service
    xml = open(resource_file('wps_CEDACapabilities.xml'), 'rb').read()
    wps.getcapabilities(xml=xml)

    # Check WPS description
    assert wps.identification.type == 'WPS'
    assert wps.identification.title == 'WPS Pylons Test Server'
    assert wps.identification.abstract is None

    # Check available operations
    operations = [op.name for op in wps.operations]
    assert operations == [
        'GetCapabilities',
        'DescribeProcess',
        'Execute']

    # Check high level process descriptions
    processes = [(p.identifier, p.title) for p in wps.processes]
    assert processes == [
        ('CDMSSubsetVariable', 'Writes a text file and returns an output.'),
        ('NCDumpIt', 'Calls ncdump on the input file path and writes it to an output file.'),
        ('TestDap', 'Writes a text file and returns an output.'),
        ('CDMSDescribeVariableDomain', 'Writes a text file and returns an output.'),
        ('CFCheck', 'Writes a text file and returns an output.'),
        ('DoubleIt', 'Doubles the input number and returns value'),
        ('SimplePlot', 'Creates a simple map plot.'),
        ('CDMSListDatasets', 'Writes a text file and returns an output.'),
        ('CDMSListVariables', 'Writes a text file and returns an output.'),
        ('WCSWrapper', 'Web Coverage Service Wrapper Process'),
        ('GetWeatherStations', 'Writes a text file with one weather station per line'),
        ('ListPPFileHeader', 'Writes a text file that contains a listing of pp-records in a file.'),
        ('TakeAges', 'A test process to last a long time.'),
        ('CMIP5FileFinder', 'Writes a test file of matched CMIP5 files.'),
        ('SubsetPPFile', 'Filters a PP-file to generate a new subset PP-file.'),
        ('ExtractUKStationData', 'ExtractUKStationData'),
        ('CDOWrapper1', 'Writes a text file and returns an output.'),
        ('MMDNCDiff', 'MMDNCDiff'),
        ('PlotRotatedGrid', 'Creates a plot - to show we can plot a rotated grid.'),
        ('MMDAsync', 'Writes a text file and returns an output.'),
        ('MashMyDataMultiplier', 'Writes a text file and returns an output.'),
        ('Delegator', 'Writes a text file and returns an output.'),
        ('ExArchProc1', 'Writes a text file and returns an output.'),
        ('CDOShowInfo', 'Writes a text file and returns an output.'),
        ('PostTest', 'Writes a text file and returns an output.'),
        ('StatusTestProcess', 'An process to test status responses'),
        ('WaitForFileDeletionCached', 'An asynchronous job that waits for a file to be deleted'),
        ('WaitForAllFilesToBeDeleted', 'An asynchronous job that waits for a number of files to be deleted'),
        ('AsyncTest', 'Does an asynchronous test job run'),
        ('SyncTest1', 'Just creates a file.'),
        ('WaitForFileDeletion', 'An asynchronous job that waits for a file to be deleted'),
        ('ProcessTemplate', 'Writes a text file and returns an output.')]
예제 #31
0
def test_wps_execute():
    wps = WebProcessingService('http://cida.usgs.gov/gdp/process/WebProcessingService')

    # Execute fake invocation of Execute operation using cached HTTP request and response
    request = open(resource_file('wps_USGSExecuteRequest1.xml'), 'rb').read()
    response = open(resource_file('wps_USGSExecuteResponse1a.xml'), 'rb').read()
    execution = wps.execute(None, [], request=request, response=response)
    assert execution.status == 'ProcessStarted'
    assert execution.isComplete() is False

    # Simulate end of process
    response = open(resource_file('wps_USGSExecuteResponse1b.xml'), 'rb').read()
    execution.checkStatus(sleepSecs=0, response=response)
    assert execution.status == 'ProcessSucceeded'
    assert execution.isComplete() is True

    # Display location of process output
    output = execution.processOutputs[0]
    assert output.reference == \
        'http://cida.usgs.gov/climate/gdp/process/RetrieveResultServlet?id=1318528582026OUTPUT.601bb3d0-547f-4eab-8642-7c7d2834459e'  # noqa
예제 #32
0
def test_wms_capabilities():
    # Fake a request to a WMS Server using saved doc from
    # http://datageo.ambiente.sp.gov.br/serviceTranslator/rest/getXml/IPT_Geoserver_WMS/Risco_Louveira/1449249453587/wms
    xml = open(resource_file('wms_datageo_caps_130.xml'), 'rb').read()
    wms = WebMapService('url', version='1.3.0', xml=xml)

    # Test capabilities
    # -----------------

    assert wms.identification.type == 'WMS'
    assert wms.identification.version == '1.3.0'
    assert wms.identification.title == 'GeoServer Web Map Service'
예제 #33
0
    def test_station(self):
        data = open(resource_file(os.path.join('ioos_swe','SML-DescribeSensor-Station.xml')), "rU").read()
        d = IoosDescribeSensor(data)

        assert d.ioos_version == "1.0"
        assert d.system.name == "urn:ioos:station:wmo:41001"
        assert d.variables   == sorted([u'http://mmisw.org/ont/cf/parameter/sea_water_temperature',
                                        u'http://mmisw.org/ont/cf/parameter/sea_water_salinity',
                                        u'http://mmisw.org/ont/cf/parameter/air_pressure',
                                        u'http://mmisw.org/ont/cf/parameter/air_temperature'])
        assert d.starting     == datetime(2008, 4, 28, 8, tzinfo=pytz.utc)
        assert d.ending       == datetime(2012, 12, 27, 19, tzinfo=pytz.utc)
예제 #34
0
def test_gm03():
    """Test GM03 parsing"""

    e = etree.parse(resource_file('gm03_example1.xml'))
    gm03 = GM03(e)
    assert gm03.header.version == '2.3'
    assert gm03.header.sender == 'geocat.ch'
    assert not hasattr(gm03.data, 'core')
    assert hasattr(gm03.data, 'comprehensive')
    assert len(gm03.data.comprehensive.elements) == 13
    assert sorted(list(gm03.data.comprehensive.elements.keys())) == [
        'address', 'citation', 'contact', 'data_identification', 'date',
        'extent', 'extent_geographic_element', 'geographic_bounding_box',
        'identification_point_of_contact', 'keywords', 'metadata',
        'metadata_point_of_contact', 'responsible_party'
    ]  # noqa
    assert isinstance(gm03.data.comprehensive.date, list)
    assert len(gm03.data.comprehensive.date) == 1
    assert gm03.data.comprehensive.metadata.file_identifier == '41ac321f632e55cebf0508a2cea5d9023fd12d9ad46edd679f2c275127c88623fb9c9d29726bef7c'  # noqa
    assert gm03.data.comprehensive.metadata.date_stamp == '1999-12-31T12:00:00'
    assert gm03.data.comprehensive.metadata.language == 'de'

    # Test TID searching

    assert gm03.data.comprehensive.metadata.tid == 'xN6509077498146737843'

    search_tid = gm03.data.comprehensive.metadata.tid
    assert gm03.data.comprehensive.get_element_by_tid('404') is None
    assert gm03.data.comprehensive.get_element_by_tid(search_tid) is not None
    search_tid2 = gm03.data.comprehensive.extent.data_identification.ref
    assert search_tid2 == 'xN8036063300808707346'
    assert gm03.data.comprehensive.get_element_by_tid(search_tid2) is not None

    e = etree.parse(resource_file('gm03_example2.xml'))
    gm03 = GM03(e)
    assert gm03.data.comprehensive.geographic_bounding_box.extent_type_code == 'false'
    assert gm03.data.comprehensive.geographic_bounding_box.north_bound_latitude == '47.1865387201702'
    assert gm03.data.comprehensive.geographic_bounding_box.south_bound_latitude == '47.1234508676764'
    assert gm03.data.comprehensive.geographic_bounding_box.east_bound_longitude == '9.10597474389878'
    assert gm03.data.comprehensive.geographic_bounding_box.west_bound_longitude == '9.23798212070671'
예제 #35
0
def test_wps_request11_bbox():
    processid = "bbox"
    bbox = BoundingBoxDataInput([51.9, 7.0, 53.0, 8.0])
    inputs = [("bbox", bbox)]

    # Build XML request for WPS process execution
    execution = WPSExecution()
    requestElement = execution.buildRequest(processid, inputs)
    request = etree.tostring(requestElement)

    # Compare to cached XML request
    _request = open(resource_file('wps_EmuExecuteRequest11.xml'), 'rb').read()
    assert compare_xml(request, _request) is True
예제 #36
0
def test_wps_request9():
    # Process input/output arguments
    processid = "helloworld"
    inputs = [("user", 'Pingu')]

    # Build XML request for WPS process execution
    execution = WPSExecution()
    requestElement = execution.buildRequest(processid, inputs)
    request = etree.tostring(requestElement)

    # Compare to cached XML request
    _request = open(resource_file('wps_EmuExecuteRequest9.xml'), 'rb').read()
    assert compare_xml(request, _request) is True
예제 #37
0
def test_decode_full_json1():
    jsondata1 = open(resource_file(os.path.join('owc_geojson_examples', 'owc1.geojson')), 'r').read()
    owc1 = OwcContext.from_json(jsondata1)
    assert owc1 is not None
    assert owc1.resources[0].temporal_extent.to_dict() == TimeIntervalFormat.from_string(
        "2013-11-02T15:24:24.446+12:00").to_dict()
    # logger.debug(owc1.to_json())
    re_owc1 = OwcContext.from_json(owc1.to_json())
    assert owc1.to_dict() == re_owc1.to_dict()

    getcapa_ops = [op for op in owc1.resources[0].offerings[0].operations if op.operations_code == "GetCapabilities"]
    assert len(getcapa_ops) > 0
    assert getcapa_ops[0].mimetype == "application/xml"
예제 #38
0
def test_decode_full_json2():
    jsondata2 = open(resource_file(os.path.join('owc_geojson_examples', 'owc2.geojson')), 'rb').read().decode('latin1')
    owc2 = OwcContext.from_json(jsondata2)
    assert owc2 is not None
    # logger.debug(owc2.to_json())
    re_owc2 = OwcContext.from_json(owc2.to_json())
    assert owc2.to_dict() == re_owc2.to_dict()

    assert owc2.creator_application.title == "Web Enterprise Suite"
    assert owc2.spec_reference[0].href == "http://www.opengis.net/spec/owc-geojson/1.0/req/core"
    assert isinstance(owc2.resources[0].geospatial_extent, dict)
    geo = owc2.resources[0].geospatial_extent
    assert geo.get('type') == "Polygon"
    assert isinstance(geo.get('coordinates'), list)
예제 #39
0
    def test_timeseries_profile_single_station(self):
        swe = open(resource_file('ioos_swe/SWE-SingleStation-TimeSeriesProfile_QC.xml'), 'rb').read()
        data_record = etree.fromstring(swe)
        station = TimeSeriesProfile(data_record).feature

        assert isinstance(station, StationProfile)

        assert station.uid        == "urn:ioos:station:wmo:41001"
        assert station.name       == "wmo_41001"
        assert station.location.x == -75.415
        assert station.location.y == 32.382
        assert station.location.z == 0.5

        # should have three profiles
        assert len(station.elements) == 3
        station.calculate_bounds()

        # should all be at the same point
        bounds = station.get_bbox()
        assert isinstance(bounds, Point)
        assert bounds.x == -75.415
        assert bounds.y == 32.382

        # time
        time_range = station.get_time_range()
        assert time_range[0].strftime("%Y-%m-%dT%H:%M:%SZ") == "2009-05-23T00:00:00Z"
        assert time_range[-1].strftime("%Y-%m-%dT%H:%M:%SZ") == "2009-05-23T02:00:00Z"

        # depth bounds
        depth_range = station.get_depth_range()
        assert depth_range[0] == -39.5
        assert depth_range[-1] == -4.5

        # spot check values
        profile = station.elements[0]

        assert profile.time.strftime("%Y-%m-%dT%H:%M:%SZ") == "2009-05-23T00:00:00Z"
        assert len(profile.elements) == 4
        assert [e.location.z for e in profile.elements] == [-39.5, -19.5, -9.5, -4.5]

        assert len(profile.elements[0].members) == 2
        assert [m['name'] for m in profile.elements[0].members] == ['direction_of_sea_water_velocity', 'sea_water_speed']
        assert [m['value'] for m in profile.elements[0].members] == [352.0, 9.6]

        sensor = station.sensors['wmo_41001_sensor1']
        assert 'sensor_orientation' in sensor
        assert sensor['sensor_orientation']['X']['name'] == 'platform_pitch_angle'
        assert sensor['sensor_orientation']['Y']['name'] == 'platform_roll_angle'
        assert sensor['sensor_orientation']['Z']['name'] == 'platform_orientation'
예제 #40
0
def test_wps_request8():
    # Process input/ouutput arguments
    processid = "wordcount"
    textdoc = ComplexDataInput("Alice was beginning to get very tired ...")
    inputs = [("text", textdoc), ]
    outputs = [("output", True), ]

    # Build XML request for WPS process execution
    execution = WPSExecution()
    requestElement = execution.buildRequest(processid, inputs, output=outputs, mode=ASYNC, lineage=True)
    request = etree.tostring(requestElement)

    # Compare to cached XML request
    _request = open(resource_file('wps_EmuExecuteRequest8.xml'), 'rb').read()
    assert compare_xml(request, _request) is True
예제 #41
0
def test_wps_request4():
    # Process input/ouutput arguments
    processid = "reprojectImage"
    inputs = [("inputImage", "http://rsg.pml.ac.uk/wps/testdata/elev_srtm_30m.img"),
              ("outputSRS", "EPSG:4326")]
    output = "outputImage"

    # build XML request for WPS process execution
    execution = WPSExecution()
    requestElement = execution.buildRequest(processid, inputs, output=[(output, True)])
    request = etree.tostring(requestElement)

    # Compare to cached XML request
    _request = open(resource_file('wps_PMLExecuteRequest4.xml'), 'rb').read()
    assert compare_xml(request, _request) is True
예제 #42
0
def test_wps_request6():
    # Process input/output arguments

    processid = "v.net.path"
    inputs = [("input", "http://rsg.pml.ac.uk/wps/example/graph.gml"),
              ("file", "1 -960123.1421801624 4665723.56559387 -101288.65106088226 5108200.011823481")]

    # Build XML request for WPS process execution
    execution = WPSExecution()
    requestElement = execution.buildRequest(processid, inputs)
    request = etree.tostring(requestElement)

    # Compare to cached XML request
    _request = open(resource_file('wps_PMLExecuteRequest6.xml'), 'rb').read()
    assert compare_xml(request, _request) is True