@@ -61,7 +61,7 @@ def test_lizmap_getserversettings(client):
61
61
62
62
63
63
def test_lizmap_service_filter_polygon_with_user (client ):
64
- """ Test get polygon filter with the Lizmap service with a user. """
64
+ """ Test get polygon filter with the Lizmap service with a user as SQL or QGIS expression . """
65
65
project_file = "test_filter_layer_data_by_polygon_for_groups.qgs"
66
66
67
67
qs = (
@@ -70,7 +70,8 @@ def test_lizmap_service_filter_polygon_with_user(client):
70
70
"REQUEST=GETSUBSETSTRING&"
71
71
"MAP=france_parts.qgs&"
72
72
"LAYER=shop_bakery&"
73
- "LIZMAP_USER_GROUPS=montferrier-sur-lez"
73
+ # "FILTER_TYPE=SQL&" SQL must be the default value when not provided
74
+ "LIZMAP_USER_GROUPS=montferrier-sur-lez&"
74
75
)
75
76
rv = client .get (qs , project_file )
76
77
assert rv .status_code == 200
@@ -79,10 +80,22 @@ def test_lizmap_service_filter_polygon_with_user(client):
79
80
80
81
b = json .loads (rv .content .decode ('utf-8' ))
81
82
83
+ # SQL as output, the default format
82
84
assert b ['filter' ] == '"id" IN ( 68 )'
83
85
assert b ['status' ] == 'success'
84
86
assert b ['polygons' ].startswith ('SRID=3857;MultiPolygon' )
85
87
88
+ # QGIS expression
89
+ qs += 'FILTER_TYPE=expression&'
90
+ rv = client .get (qs , project_file )
91
+ assert rv .status_code == 200
92
+ assert rv .headers .get ('Content-Type' , '' ).find ('application/json' ) == 0
93
+ b = json .loads (rv .content .decode ('utf-8' ))
94
+ # geom_from_wkt is a QGIS expression subset
95
+ assert 'geom_from_wkt' in b ['filter' ]
96
+ assert b ['status' ] == 'success'
97
+ assert b ['polygons' ].startswith ('SRID=3857;MultiPolygon' )
98
+
86
99
87
100
def test_lizmap_service_filter_polygon_without_user (client ):
88
101
""" Test get polygon filter with the Lizmap service without a user. """
0 commit comments