예제 #1
0
##################################################################
# Copyright 2018 Open Source Geospatial Foundation and others    #
# licensed under MIT, Please consult LICENSE.txt for details     #
##################################################################

import unittest
from pywps import Process, Service, get_ElementMakerForVersion
from pywps.app.basic import get_xpath_ns
from pywps.tests import assert_pywps_version, client_for
import lxml.etree

import re

VERSION="1.0.0"
WPS, OWS = get_ElementMakerForVersion(VERSION)
xpath_ns = get_xpath_ns(VERSION)

class ExceptionsTest(unittest.TestCase):

    def setUp(self):
        self.client = client_for(Service(processes=[]))

    def test_invalid_parameter_value(self):
        resp = self.client.get('?service=wms')
        exception_el = resp.xpath('/ows:ExceptionReport/ows:Exception')[0]
        assert exception_el.attrib['exceptionCode'] == 'InvalidParameterValue'
        assert resp.status_code == 400
        assert re.match('text/xml(;\s*charset=.*)?', resp.headers['Content-Type'])
        assert_pywps_version(resp)

    def test_missing_parameter_value(self):
예제 #2
0
 def set_version(self, version):
     self.version = version
     self.xpath_ns = get_xpath_ns(version)
     self.WPS, self.OWS = get_ElementMakerForVersion(self.version)
예제 #3
0
from pywps._compat import StringIO
if PY2:
    from owslib.ows import BoundingBox

try:
    import netCDF4
except ImportError:
    WITH_NC4 = False
else:
    WITH_NC4 = True

DATA_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data')

VERSION = "1.0.0"

WPS, OWS = get_ElementMakerForVersion(VERSION)

xpath_ns = get_xpath_ns(VERSION)


def create_ultimate_question():
    def handler(request, response):
        response.outputs['outvalue'].data = '42'
        return response

    return Process(handler=handler,
                   identifier='ultimate_question',
                   title='Ultimate Question',
                   outputs=[
                       LiteralOutput('outvalue',
                                     'Output Value',
예제 #4
0
파일: execute.py 프로젝트: tlvu/pywps
from werkzeug.wrappers import Request
from pywps import get_ElementMakerForVersion
from pywps.exceptions import NoApplicableCode
import pywps.configuration as config
from werkzeug.wrappers import Response

from pywps.response.status import WPS_STATUS
from pywps.response import WPSResponse
from pywps.inout.formats import FORMATS

import urllib.parse as urlparse
from urllib.parse import urlencode

LOGGER = logging.getLogger("PYWPS")

WPS, OWS = get_ElementMakerForVersion("1.0.0")


class ExecuteResponse(WPSResponse):
    def __init__(self, wps_request, uuid, **kwargs):
        """constructor

        :param pywps.app.WPSRequest.WPSRequest wps_request:
        :param pywps.app.Process.Process process:
        :param uuid: string this request uuid
        """

        super(self.__class__, self).__init__(wps_request, uuid)

        self.process = kwargs["process"]
        self.outputs = {o.identifier: o for o in self.process.outputs}
예제 #5
0
 def set_version(self, version):
     self.version = version
     self.xpath_ns = get_xpath_ns(version)
     self.WPS, self.OWS = get_ElementMakerForVersion(self.version)
예제 #6
0
파일: execute.py 프로젝트: bird-house/pywps
from pywps.response.status import WPS_STATUS
from pywps.response import WPSResponse

from pywps._compat import PY2

if PY2:
    import urlparse
    from urllib import urlencode
else:
    import urllib.parse as urlparse
    from urllib.parse import urlencode

LOGGER = logging.getLogger("PYWPS")

WPS, OWS = get_ElementMakerForVersion("1.0.0")


class ExecuteResponse(WPSResponse):

    def __init__(self, wps_request, uuid, **kwargs):
        """constructor

        :param pywps.app.WPSRequest.WPSRequest wps_request:
        :param pywps.app.Process.Process process:
        :param uuid: string this request uuid
        """

        super(self.__class__, self).__init__(wps_request, uuid)

        self.process = kwargs["process"]