File: test_wps_execute_language.py

package info (click to toggle)
owslib 0.23.0-1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,176 kB
  • sloc: xml: 137,886; python: 20,041; makefile: 167; sh: 11
file content (31 lines) | stat: -rw-r--r-- 1,007 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from owslib.wps import WebProcessingService
import owslib.wps


def test_wps_execute_language(monkeypatch):

    def raise_on_log_error(*a):
        """Make sure the errors are raised, not only caught and logged"""
        raise AssertionError

    monkeypatch.setattr(owslib.wps.log, "error", raise_on_log_error)

    monkeypatch.setattr(owslib.wps.WPSExecution, "parseResponse", lambda *a: None)
    wps = WebProcessingService('http://www.example.com', language='fr-CA', skip_caps=True)
    execution = wps.execute('test', [], response=b'<xml></xml>')

    assert b'language="fr-CA"' in execution.request

    def mock_open_url(*args, **kwargs):
        assert 'language=fr-CA' in args[1]

        class FakeResponse:
            def read(self):
                return b'<xml></xml>'

        return FakeResponse()

    monkeypatch.setattr(owslib.wps, "openURL", mock_open_url)

    execution.status = 'ProcessSucceeded'
    execution.checkStatus(url='http://www.example.com', response=None, sleepSecs=0)