本文整理汇总了Python中tests.utils.resource_file函数的典型用法代码示例。如果您正苦于以下问题:Python resource_file函数的具体用法?Python resource_file怎么用?Python resource_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resource_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wps_response6
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: test_wps_getcapabilities_52n
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')]
示例3: test_timeseries_multiple_sensor_data_choice
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
示例4: test_wps_describeprocess_ceda
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'
示例5: wps
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
示例6: test_wps_literal_data_input_parsing_references
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'
示例7: test_single_atomxml_coding
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()
示例8: test_wps_execute_invalid_request
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'
示例9: test_wps_request3
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
示例10: test_o_and_m_get_observation
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: test_ows_interfaces_wms
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: test_timeseries_multi_station_multi_sensor
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
示例13: test_decode_full_json3
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 == "[email protected]"
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"
示例14: test_wps_describeprocess_bbox
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'
示例15: test_wps_getcapabilities_usgs
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
]