Skip to content

Commit

Permalink
Add test fo /api/config REST API.
Browse files Browse the repository at this point in the history
  • Loading branch information
wlorenzetti committed Oct 19, 2023
1 parent b33eb4a commit f3a739b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Binary file modified g3w-admin/qdjango/tests/data/geodata/qgis_widget_test_data.gpkg
Binary file not shown.
43 changes: 43 additions & 0 deletions g3w-admin/qdjango/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ def test_tokenfilter_mode_api(self):
'state': 'created'
})


# Filter for layer cities: DELETE
resp = json.loads(self._testApiCall('core-vector-api',
['filtertoken', 'qdjango', self.project310.instance.pk,
Expand Down Expand Up @@ -1207,6 +1208,48 @@ def test_tokenfilter_mode_api(self):
self.assertFalse(token == sf.token)
self.assertEqual(sf.stf_layers.all()[0].qgs_expr, '$id NOT IN (6,8,9,0)')

# Filter for layer check /api/config REST API:
resp = json.loads(self._testApiCall('group-project-map-config',
[
self.project310.instance.group.slug,
'qdjango',
self.project310.instance.pk], logout=False).content
)

for l in resp['layers']:
if l['id'] == cities.qgs_layer_id:
self.assertTrue('filters' in l)
self.assertEqual(len(l['filters']), 1)
else:
self.assertFalse('filters' in l)

# Filter for layer cities: DELETE
resp = json.loads(self._testApiCall('core-vector-api',
['filtertoken', 'qdjango', self.project310.instance.pk,
cities.qgs_layer_id],
{
'mode': 'delete_saved',
'fid': '1'
}, logout=False).content)

# Check the db
fls = FilterLayerSaved.objects.filter(layer=cities)
self.assertEqual(len(fls), 0)

resp = json.loads(self._testApiCall('group-project-map-config',
[
self.project310.instance.group.slug,
'qdjango',
self.project310.instance.pk], logout=False).content
)

for l in resp['layers']:
if l['id'] == cities.qgs_layer_id:
self.assertFalse('filters' in l)
else:
self.assertFalse('filters' in l)




def test_download_vector_api_selected_wms_fields(self):
Expand Down

0 comments on commit f3a739b

Please sign in to comment.