@@ -61,7 +61,7 @@ def test_lizmap_getserversettings(client):
6161
6262
6363def 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 . """
6565 project_file = "test_filter_layer_data_by_polygon_for_groups.qgs"
6666
6767 qs = (
@@ -70,7 +70,8 @@ def test_lizmap_service_filter_polygon_with_user(client):
7070 "REQUEST=GETSUBSETSTRING&"
7171 "MAP=france_parts.qgs&"
7272 "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&"
7475 )
7576 rv = client .get (qs , project_file )
7677 assert rv .status_code == 200
@@ -79,10 +80,22 @@ def test_lizmap_service_filter_polygon_with_user(client):
7980
8081 b = json .loads (rv .content .decode ('utf-8' ))
8182
83+ # SQL as output, the default format
8284 assert b ['filter' ] == '"id" IN ( 68 )'
8385 assert b ['status' ] == 'success'
8486 assert b ['polygons' ].startswith ('SRID=3857;MultiPolygon' )
8587
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+
8699
87100def test_lizmap_service_filter_polygon_without_user (client ):
88101 """ Test get polygon filter with the Lizmap service without a user. """
0 commit comments