|
1 | | -import pytest |
2 | 1 | import os |
| 2 | +import requests |
3 | 3 | from pywps import Service |
4 | 4 | from pywps.tests import assert_response_success |
5 | 5 |
|
6 | | -from .common import client_for |
7 | | -import emu |
| 6 | +from .common import client_for, resource_file, TESTS_HOME, WPS, OWS, get_output |
8 | 7 | from emu.processes.wps_poly_centroid import PolyCentroid |
9 | | -from eggshell.config import Paths |
10 | 8 |
|
11 | | -paths = Paths(emu) |
12 | | -TESTS_HOME = os.path.abspath(os.path.dirname(__file__)) |
13 | 9 | cfgfiles = os.path.join(TESTS_HOME, 'test.cfg') |
14 | 10 |
|
15 | 11 |
|
16 | | -def test_wps_poly_centroid(): |
| 12 | +def test_wps_poly_centroid_get(): |
17 | 13 | client = client_for(Service(processes=[PolyCentroid(), ], cfgfiles=cfgfiles)) |
18 | | - fn = os.path.join(TESTS_HOME, 'testdata', 'poly.xml') |
19 | | - datainputs = "polygon=files@xlink:href=file://{0}".format(fn) |
| 14 | + datainputs = "polygon=@xlink:href=file://{0}".format(resource_file('poly.xml')) |
20 | 15 | resp = client.get( |
21 | 16 | service='WPS', request='Execute', version='1.0.0', |
22 | 17 | identifier='poly_centroid', |
23 | 18 | datainputs=datainputs) |
24 | 19 | assert_response_success(resp) |
| 20 | + assert get_output(resp.xml) == {'output': "119.59740,-13.57388"} |
| 21 | + |
| 22 | + |
| 23 | +def test_wps_poly_centroid_post(): |
| 24 | + client = client_for(Service(processes=[PolyCentroid(), ], cfgfiles=cfgfiles)) |
| 25 | + request_doc = WPS.Execute( |
| 26 | + OWS.Identifier('poly_centroid'), |
| 27 | + WPS.DataInputs( |
| 28 | + WPS.Input( |
| 29 | + OWS.Identifier('polygon'), |
| 30 | + WPS.Data(WPS.ComplexData(open(resource_file('poly.xml'), 'r').read())) |
| 31 | + ) |
| 32 | + ), |
| 33 | + version='1.0.0' |
| 34 | + ) |
| 35 | + resp = client.post_xml(doc=request_doc) |
| 36 | + assert_response_success(resp) |
| 37 | + assert get_output(resp.xml) == {'output': "119.59740,-13.57388"} |
0 commit comments