File: test_wps_execute_language.py

package info (click to toggle)
owslib 0.35.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,772 kB
  • sloc: xml: 143,288; python: 24,542; makefile: 15
file content (31 lines) | stat: -rw-r--r-- 982 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
import logging
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(logging, "error", raise_on_log_error)

    monkeypatch.setattr(owslib.wps.WPSExecution, "parseResponse", lambda *a: None)
    wps = owslib.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)