Coverage for gws-app/gws/plugin/ows_server/wfs/_test/_test.py: 100%
23 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 23:09 +0200
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 23:09 +0200
1import gws
2import gws.test.util as u
3import gws.lib.xmlx.validator
6@u.fixture(scope='module')
7def root():
8 cfg = """
9 permissions.all "allow all"
11 actions [
12 { type "ows" }
13 ]
15 owsServices+ {
16 type "wfs"
17 uid "WFS_1"
18 }
19 owsServices+ {
20 type "wfs"
21 uid "WFS_1_INSPIRE"
22 withInspireMeta true
23 metadata {DEFAULT_METADATA}
24 }
25 helpers+ {
26 type "xml"
27 namespaces+ {
28 xmlns "demo"
29 uri "http://localhost/_/owsXml/namespace/demo"
30 }
31 }
33 projects+ {
34 uid "PROJECT_1"
35 metadata.abstract "ABSTRACT"
36 metadata.keywords ["aaa" "bbb"]
37 map.extent [0 0 100 200]
38 map.srs "EPSG:3857"
39 map.layers+ {
40 uid "LAYER_1"
41 title "LAYER_1"
42 type "geojson"
43 provider.path "/gws-app/gws/plugin/ows_server/wfs/_test/1.geojson"
44 ows.xmlns "demo"
45 withSearch true
46 }
47 }
48 """
49 yield u.gws_root(cfg, DEFAULT_METADATA=u.DEFAULT_METADATA)
52def test_valid_GetCapabilities(root: gws.Root):
53 s = u.http.get(
54 root,
55 '/_/owsService',
56 query_string={
57 'request': 'GetCapabilities',
58 'serviceUid': 'WFS_1',
59 'projectUid': 'PROJECT_1',
60 'version': '2.0.2',
61 },
62 )
63 gws.u.write_file_b(f'{gws.c.VAR_DIR}/wfs_GetCapabilities.xml', s.get_data())
64 assert gws.lib.xmlx.validator.validate(s.get_data())
67def test_valid_GetCapabilities_inspire(root: gws.Root):
68 s = u.http.get(
69 root,
70 '/_/owsService',
71 query_string={
72 'request': 'GetCapabilities',
73 'serviceUid': 'WFS_1_INSPIRE',
74 'projectUid': 'PROJECT_1',
75 'version': '2.0.2',
76 },
77 )
78 gws.u.write_file_b(f'{gws.c.VAR_DIR}/wfs_GetCapabilities_inspire.xml', s.get_data())
79 assert gws.lib.xmlx.validator.validate(s.get_data())
82def test_valid_GetFeature(root: gws.Root):
83 s = u.http.get(
84 root,
85 '/_/owsService',
86 query_string={
87 'request': 'GetFeature',
88 'serviceUid': 'WFS_1',
89 'projectUid': 'PROJECT_1',
90 'version': '2.0.2',
91 },
92 )
93 gws.u.write_file_b(f'{gws.c.VAR_DIR}/wfs_GetFeature.xml', s.get_data())
94 assert gws.lib.xmlx.validator.validate(s.get_data())
96def test_valid_DescribeFeatureType(root: gws.Root):
97 s = u.http.get(
98 root,
99 '/_/owsService',
100 query_string={
101 'request': 'DescribeFeatureType',
102 'serviceUid': 'WFS_1',
103 'projectUid': 'PROJECT_1',
104 'version': '2.0.2',
105 },
106 )
107 gws.u.write_file_b(f'{gws.c.VAR_DIR}/wfs_DescribeFeatureType.xml', s.get_data())
108 assert gws.lib.xmlx.validator.validate(s.get_data())