Coverage for gws-app/gws/base/map/_test/action_test.py: 100%
17 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 22:59 +0200
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 22:59 +0200
1import gws
2import gws.test.util as u
5@u.fixture(scope='module')
6def root():
7 u.pg.create('plain', {'id': 'int primary key', 'name': 'text', 'g': 'geometry(point,3857)'})
8 u.pg.insert('plain', [
9 dict(id=1, name='a11', g=u.ewkb('POINT(10 100)')),
10 dict(id=2, name='a22', g=u.ewkb('POINT(20 200)')),
11 dict(id=3, name='a33', g=u.ewkb('POINT(30 300)')),
12 ])
14 cfg = '''
15 permissions.all "allow all"
17 models+ {
18 uid "PLAIN" type "postgres" tableName "plain"
19 }
20 actions+ {
21 uid 'ACTION'
22 type 'map'
23 }
24 projects+ {
25 uid "A"
26 permissions.all "allow all"
27 map.layers+ {
28 uid "LAYER"
29 type "postgres"
30 tableName "plain"
31 templates+ {
32 subject "feature.label"
33 type "html"
34 text "--{id}/{name}--"
35 }
36 }
37 }
38 '''
40 yield u.gws_root(cfg)
43def test_get_features(root: gws.Root):
44 res = u.http.get(root, '/_/mapGetFeatures/layerUid/LAYER')
45 fs = res.json['features']
47 assert fs[0]['attributes'] == {'uid': 1, 'geometry': {'crs': 'EPSG:3857', 'geometry': {'type': 'Point', 'coordinates': [10.0, 100.0]}}}
48 assert fs[1]['attributes'] == {'uid': 2, 'geometry': {'crs': 'EPSG:3857', 'geometry': {'type': 'Point', 'coordinates': [20.0, 200.0]}}}
49 assert fs[2]['attributes'] == {'uid': 3, 'geometry': {'crs': 'EPSG:3857', 'geometry': {'type': 'Point', 'coordinates': [30.0, 300.0]}}}
51 assert fs[0]['views']['label'] == '--1/a11--'
52 assert fs[1]['views']['label'] == '--2/a22--'
53 assert fs[2]['views']['label'] == '--3/a33--'