g3w-admin-processing 1.2.1b1.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- g3w_admin_processing-1.2.1b1.dev1.dist-info/METADATA +258 -0
- g3w_admin_processing-1.2.1b1.dev1.dist-info/RECORD +80 -0
- g3w_admin_processing-1.2.1b1.dev1.dist-info/WHEEL +5 -0
- g3w_admin_processing-1.2.1b1.dev1.dist-info/licenses/LICENSE +373 -0
- g3w_admin_processing-1.2.1b1.dev1.dist-info/top_level.txt +1 -0
- qprocessing/__init__.py +7 -0
- qprocessing/admin.py +21 -0
- qprocessing/api/__init__.py +0 -0
- qprocessing/api/permissions.py +41 -0
- qprocessing/api/views/__init__.py +4 -0
- qprocessing/api/views/actions.py +84 -0
- qprocessing/api/views/admin.py +76 -0
- qprocessing/api/views/models.py +219 -0
- qprocessing/api/views/upload.py +177 -0
- qprocessing/apiurls.py +64 -0
- qprocessing/apps.py +38 -0
- qprocessing/configs.py +131 -0
- qprocessing/forms.py +133 -0
- qprocessing/migrations/0001_initial.py +24 -0
- qprocessing/migrations/0002_auto_20230615_1609.py +23 -0
- qprocessing/migrations/0003_qprocessinginputupload.py +32 -0
- qprocessing/migrations/0004_auto_20230809_0920.py +26 -0
- qprocessing/migrations/0005_alter_qprocessinginputupload_user.py +21 -0
- qprocessing/migrations/__init__.py +0 -0
- qprocessing/models.py +143 -0
- qprocessing/receivers.py +100 -0
- qprocessing/sitetrees.py +31 -0
- qprocessing/static/qprocessing/js/components/DrawInputVectorFeatures.js +180 -0
- qprocessing/static/qprocessing/js/components/InputFieldChooser.js +226 -0
- qprocessing/static/qprocessing/js/components/InputPrjRasterLayer.js +135 -0
- qprocessing/static/qprocessing/js/components/InputPrjVectorLayer.js +415 -0
- qprocessing/static/qprocessing/js/components/ModelPanel.js +496 -0
- qprocessing/static/qprocessing/js/components/ModelResults.js +73 -0
- qprocessing/static/qprocessing/js/components/OutputFile.js +63 -0
- qprocessing/static/qprocessing/js/components/OutputRasterLayer.js +63 -0
- qprocessing/static/qprocessing/js/components/OutputVectorLayer.js +115 -0
- qprocessing/static/qprocessing/js/components/UploadVectorFile.js +53 -0
- qprocessing/static/qprocessing/js/i18n/en.js +33 -0
- qprocessing/static/qprocessing/js/i18n/index.js +7 -0
- qprocessing/static/qprocessing/js/i18n/it.js +33 -0
- qprocessing/static/qprocessing/js/plugin.js +122 -0
- qprocessing/tasks.py +136 -0
- qprocessing/templates/qprocessing/project_form.html +70 -0
- qprocessing/templates/qprocessing/projects_list.html +72 -0
- qprocessing/tests/__init__.py +0 -0
- qprocessing/tests/base.py +104 -0
- qprocessing/tests/data/models/qbuffer.model3 +233 -0
- qprocessing/tests/data/models/qintersection.model3 +288 -0
- qprocessing/tests/data/models/qpointspolygons.model3 +222 -0
- qprocessing/tests/data/models/test.model3 +321 -0
- qprocessing/tests/data/models/test_buffer_all_inputs.model3 +269 -0
- qprocessing/tests/data/models/test_buffer_layer1.model3 +201 -0
- qprocessing/tests/data/project_data/buildings.geojson +15 -0
- qprocessing/tests/data/project_data/qprocessing.gpkg +0 -0
- qprocessing/tests/data/qprocessing_qprocessing.qgs +2813 -0
- qprocessing/tests/data/qprocessing_qprocessing_attachments.zip +0 -0
- qprocessing/tests/data/test_qgis_328.qgs +954 -0
- qprocessing/tests/data/test_qgis_328_attachments.zip +0 -0
- qprocessing/tests/data/upload/fail_shp_to_upload.zip +0 -0
- qprocessing/tests/data/upload/linestring_to_upload.geojson +9 -0
- qprocessing/tests/data/upload/point_to_upload.geojson +10 -0
- qprocessing/tests/data/upload/point_to_upload_espg4326.geojson +10 -0
- qprocessing/tests/data/upload/point_to_upload_espg4326.qmd +26 -0
- qprocessing/tests/data/upload/polygon_to_upload.geojson +9 -0
- qprocessing/tests/data/upload/shp_to_upload.cpg +1 -0
- qprocessing/tests/data/upload/shp_to_upload.dbf +0 -0
- qprocessing/tests/data/upload/shp_to_upload.prj +1 -0
- qprocessing/tests/data/upload/shp_to_upload.qix +0 -0
- qprocessing/tests/data/upload/shp_to_upload.shp +0 -0
- qprocessing/tests/data/upload/shp_to_upload.shx +0 -0
- qprocessing/tests/data/upload/shp_to_upload.zip +0 -0
- qprocessing/tests/test_algorithm.py +52 -0
- qprocessing/tests/test_api.py +173 -0
- qprocessing/tests/test_api_models.py +459 -0
- qprocessing/urls.py +33 -0
- qprocessing/utils/__init__.py +0 -0
- qprocessing/utils/data.py +283 -0
- qprocessing/utils/exceptions.py +20 -0
- qprocessing/utils/formtypes.py +521 -0
- qprocessing/views.py +96 -0
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "FeatureCollection",
|
|
3
|
+
"name": "linestring_to_upload",
|
|
4
|
+
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3857" } },
|
|
5
|
+
"features": [
|
|
6
|
+
{ "type": "Feature", "properties": { "id": 1, "name": "Sword" }, "geometry": { "type": "LineString", "coordinates": [ [ 1118743.978042365983129, 6002646.006447710096836 ], [ 1004158.244331872672774, 6242427.264027075842023 ], [ 1146329.432454151567072, 6335793.417420811019838 ], [ 1171792.928834260907024, 6520403.766176605597138 ] ] } },
|
|
7
|
+
{ "type": "Feature", "properties": { "id": 2, "name": "Knife" }, "geometry": { "type": "LineString", "coordinates": [ [ 1307598.242861512117088, 5699206.007918071001768 ], [ 1492208.59161730716005, 5909279.853053974919021 ], [ 1721380.059038293547928, 5786206.287216778844595 ] ] } }
|
|
8
|
+
]
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "FeatureCollection",
|
|
3
|
+
"name": "point_to_upload",
|
|
4
|
+
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3857" } },
|
|
5
|
+
"features": [
|
|
6
|
+
{ "type": "Feature", "properties": { "id": 1, "name": "Mars" }, "geometry": { "type": "Point", "coordinates": [ 1118743.978042365983129, 6002646.006447710096836 ] } },
|
|
7
|
+
{ "type": "Feature", "properties": { "id": 2, "name": "Moon" }, "geometry": { "type": "Point", "coordinates": [ 1437037.682793735992163, 5864718.734388783574104 ] } },
|
|
8
|
+
{ "type": "Feature", "properties": { "id": 3, "name": "Jupiter" }, "geometry": { "type": "Point", "coordinates": [ 1150573.34851750312373, 5758620.832804992794991 ] } }
|
|
9
|
+
]
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "FeatureCollection",
|
|
3
|
+
"name": "point_to_upload_espg4326",
|
|
4
|
+
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
|
|
5
|
+
"features": [
|
|
6
|
+
{ "type": "Feature", "properties": { "id": 1, "name": "Mars" }, "geometry": { "type": "Point", "coordinates": [ 10.049848144921315, 47.369805367743531 ] } },
|
|
7
|
+
{ "type": "Feature", "properties": { "id": 2, "name": "Moon" }, "geometry": { "type": "Point", "coordinates": [ 12.909129143093137, 46.523980281201418 ] } },
|
|
8
|
+
{ "type": "Feature", "properties": { "id": 3, "name": "Jupiter" }, "geometry": { "type": "Point", "coordinates": [ 10.335776244738499, 45.864243886329845 ] } }
|
|
9
|
+
]
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
|
|
2
|
+
<qgis version="3.28.9-Firenze">
|
|
3
|
+
<identifier></identifier>
|
|
4
|
+
<parentidentifier></parentidentifier>
|
|
5
|
+
<language></language>
|
|
6
|
+
<type>dataset</type>
|
|
7
|
+
<title></title>
|
|
8
|
+
<abstract></abstract>
|
|
9
|
+
<links/>
|
|
10
|
+
<fees></fees>
|
|
11
|
+
<encoding></encoding>
|
|
12
|
+
<crs>
|
|
13
|
+
<spatialrefsys nativeFormat="Wkt">
|
|
14
|
+
<wkt>PROJCRS["WGS 84 / Pseudo-Mercator",BASEGEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],ID["EPSG",4326]],CONVERSION["Popular Visualisation Pseudo-Mercator",METHOD["Popular Visualisation Pseudo Mercator",ID["EPSG",1024]],PARAMETER["Latitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8801]],PARAMETER["Longitude of natural origin",0,ANGLEUNIT["degree",0.0174532925199433],ID["EPSG",8802]],PARAMETER["False easting",0,LENGTHUNIT["metre",1],ID["EPSG",8806]],PARAMETER["False northing",0,LENGTHUNIT["metre",1],ID["EPSG",8807]]],CS[Cartesian,2],AXIS["easting (X)",east,ORDER[1],LENGTHUNIT["metre",1]],AXIS["northing (Y)",north,ORDER[2],LENGTHUNIT["metre",1]],USAGE[SCOPE["Web mapping and visualisation."],AREA["World between 85.06°S and 85.06°N."],BBOX[-85.06,-180,85.06,180]],ID["EPSG",3857]]</wkt>
|
|
15
|
+
<proj4>+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs</proj4>
|
|
16
|
+
<srsid>3857</srsid>
|
|
17
|
+
<srid>3857</srid>
|
|
18
|
+
<authid>EPSG:3857</authid>
|
|
19
|
+
<description>WGS 84 / Pseudo-Mercator</description>
|
|
20
|
+
<projectionacronym>merc</projectionacronym>
|
|
21
|
+
<ellipsoidacronym>EPSG:7030</ellipsoidacronym>
|
|
22
|
+
<geographicflag>false</geographicflag>
|
|
23
|
+
</spatialrefsys>
|
|
24
|
+
</crs>
|
|
25
|
+
<extent/>
|
|
26
|
+
</qgis>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "FeatureCollection",
|
|
3
|
+
"name": "polygon_to_upload",
|
|
4
|
+
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3857" } },
|
|
5
|
+
"features": [
|
|
6
|
+
{ "type": "Feature", "properties": { "id": 1, "name": "Thor" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 898060.342748082592152, 6316695.795135729014874 ], [ 1078426.775440525729209, 6055694.957239605486393 ], [ 1188768.59308766759932, 6223329.641741993837059 ], [ 1167549.012770909350365, 6397330.200339409522712 ], [ 898060.342748082592152, 6316695.795135729014874 ] ] ] } },
|
|
7
|
+
{ "type": "Feature", "properties": { "id": 2, "name": "Locki" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1316086.074988215696067, 6777160.68800937756896 ], [ 1585574.745011042337865, 6817477.890611218288541 ], [ 1581330.828947690781206, 6581940.549095204100013 ], [ 1391523.050591645995155, 6550057.488069934770465 ], [ 1095402.439693931955844, 6550111.178620067425072 ], [ 1133597.684264096431434, 6719867.821154131554067 ], [ 1316086.074988215696067, 6777160.68800937756896 ] ] ] } }
|
|
8
|
+
]
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
UTF-8
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""" testign module for QGIS Processign API
|
|
3
|
+
.. note:: This program is free software; you can redistribute it and/or modify
|
|
4
|
+
it under the terms of the Mozilla Public License 2.0.
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__author__ = 'lorenzetti@gis3w.it'
|
|
9
|
+
__date__ = '2023-05-23'
|
|
10
|
+
__copyright__ = 'Copyright 2015 - 2023, Gis3w'
|
|
11
|
+
__license__ = 'MPL 2.0'
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
from django.test import TestCase
|
|
15
|
+
from qprocessing.utils.data import QProcessingModel
|
|
16
|
+
from .base import CURRENT_PATH, TEST_BASE_PATH, TestQProcessingBase
|
|
17
|
+
|
|
18
|
+
from qgis.core import QgsProcessingContext, QgsProcessingFeedback, QgsProject
|
|
19
|
+
import os
|
|
20
|
+
|
|
21
|
+
class TestQprocessingAlgorithm(TestQProcessingBase):
|
|
22
|
+
|
|
23
|
+
def test_run(self):
|
|
24
|
+
"""
|
|
25
|
+
Test running QGIS processing running
|
|
26
|
+
"""
|
|
27
|
+
qpm = QProcessingModel(str(self.model_file))
|
|
28
|
+
prj = QgsProject()
|
|
29
|
+
loaded = prj.read(self.qgis_file)
|
|
30
|
+
|
|
31
|
+
self.assertTrue(loaded)
|
|
32
|
+
self.assertTrue(prj.mapLayer('buildings_7783caca_93e9_4c17_9770_1fd8e82f7109').isValid())
|
|
33
|
+
|
|
34
|
+
#ingresso1 = './buildings.geojson'
|
|
35
|
+
ingresso1 = os.path.join(CURRENT_PATH, TEST_BASE_PATH, 'project_data/buildings.geojson')
|
|
36
|
+
result_path = os.path.join(CURRENT_PATH, TEST_BASE_PATH, 'processing_result', 'out.shp')
|
|
37
|
+
|
|
38
|
+
params = {
|
|
39
|
+
'buffer_distance': 1000,
|
|
40
|
+
'ingresso1': ingresso1,
|
|
41
|
+
'layer_bufferd': result_path
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ctx = QgsProcessingContext()
|
|
45
|
+
ctf = QgsProcessingFeedback()
|
|
46
|
+
ctx.setProject(prj)
|
|
47
|
+
|
|
48
|
+
res = qpm.model.processAlgorithm(params, ctx, ctf)
|
|
49
|
+
|
|
50
|
+
aspected_res = {'CHILD_INPUTS': {'native:buffer_1': {'DISSOLVE': False, 'DISTANCE': 1000, 'END_CAP_STYLE': 0, 'INPUT': '/home/walter/PycharmProjects/g3w_suite_qgis_api/plugins/g3w-admin-processing/qprocessing/tests/data/project_data/buildings.geojson', 'JOIN_STYLE': 0, 'MITER_LIMIT': None, 'OUTPUT': '/home/walter/PycharmProjects/g3w_suite_qgis_api/plugins/g3w-admin-processing/qprocessing/tests/data/processing_result/out.shp', 'SEGMENTS': None}}, 'CHILD_RESULTS': {'native:buffer_1': {'OUTPUT': '/home/walter/PycharmProjects/g3w_suite_qgis_api/plugins/g3w-admin-processing/qprocessing/tests/data/processing_result/out.shp'}}, 'layer_bufferd': '/home/walter/PycharmProjects/g3w_suite_qgis_api/plugins/g3w-admin-processing/qprocessing/tests/data/processing_result/out.shp'}
|
|
51
|
+
|
|
52
|
+
self.assertEqual(res, aspected_res)
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# coding=utf-8
|
|
2
|
+
"""" Test API (REST and non-REST) of qprocessing g3w-suite plugins.
|
|
3
|
+
|
|
4
|
+
.. note:: This program is free software; you can redistribute it and/or modify
|
|
5
|
+
it under the terms of the Mozilla Public License 2.0.
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__author__ = 'lorenzetti@gis3w.it'
|
|
10
|
+
__date__ = '2023-05-10'
|
|
11
|
+
__copyright__ = 'Copyright 2015 - 2023, Gis3w'
|
|
12
|
+
__license__ = 'MPL 2.0'
|
|
13
|
+
|
|
14
|
+
from django.urls import reverse
|
|
15
|
+
from core.utils.qgisapi import get_qgs_project
|
|
16
|
+
from qprocessing.utils.data import QProcessingModel
|
|
17
|
+
from .base import TestQProcessingBase
|
|
18
|
+
import json
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TestQProcessingUtils(TestQProcessingBase):
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_data(self):
|
|
26
|
+
"""
|
|
27
|
+
Test qprocessing.utils.data module classes and functions
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
# Testing QProcessingModel
|
|
31
|
+
# =========================================================
|
|
32
|
+
|
|
33
|
+
# Testing render2dict
|
|
34
|
+
# ------------------------------------------------
|
|
35
|
+
|
|
36
|
+
qpm = QProcessingModel(self.model_file)
|
|
37
|
+
|
|
38
|
+
# Testing render2dict
|
|
39
|
+
aspected_dict = {'name': 'test_buffer_all_inputs', 'display_name': 'test_buffer_all_inputs', 'inputs': [{'name': 'buffer_distance', 'label': 'Buffer distance', 'type': 'float', 'qprocessing_type': 'distance', 'default': 1000.0, 'editable': True, 'validate': {'required': True}, 'input': {'type': 'range', 'options': {'default': 1000.0, 'values': [{'min': 10.0, 'max': 20000.0, 'step': 1}]}}}, {'name': 'buffer_miter_limit', 'label': 'Buffer miter limit', 'type': 'integer', 'qprocessing_type': 'number', 'default': 2.0, 'editable': True, 'validate': {'required': True}, 'input': {'type': 'range', 'options': {'default': 2.0, 'values': [{'min': 0.0, 'max': 10.0, 'step': 1}]}}}, {'name': 'buffer_segments', 'label': 'Buffer segments', 'type': 'integer', 'qprocessing_type': 'number', 'default': 2.0, 'editable': True, 'validate': {'required': True}, 'input': {'type': 'range', 'options': {'default': 2.0, 'values': [{'min': 0.0, 'max': 10.0, 'step': 1}]}}}, {'name': 'ingresso1', 'label': 'Ingresso1', 'type': 'varchar', 'qprocessing_type': 'vector', 'default': None, 'editable': True, 'validate': {'required': True}, 'input': {'type': 'prjvectorlayer', 'options': {'datatypes': ['polygon'], 'values': []}}}], 'outputs': [{'name': 'layer_bufferd', 'label': 'Layer bufferd', 'qprocessing_type': 'outputVector', 'type': 'varchar', 'default': None, 'validate': {'required': True}, 'input': {'type': 'outputvectorlayer', 'options': {'values': [{'value': 'shp', 'key': 'Shapefile'}, {'value': 'geojson', 'key': 'GeoJSON'}, {'value': 'kml', 'key': 'KML'}, {'value': 'kmz', 'key': 'KMZ'}]}}}]}
|
|
40
|
+
self.assertEqual(qpm.render2dict(), aspected_dict)
|
|
41
|
+
|
|
42
|
+
# Testing make_model_params
|
|
43
|
+
# -------------------------------------------------
|
|
44
|
+
form_data = {
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class TestQProcessingActionAPIREST(TestQProcessingBase):
|
|
51
|
+
"""
|
|
52
|
+
Test for API REST general Actions
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def test_action_fields(self):
|
|
56
|
+
"""
|
|
57
|
+
Testing of `actions/fields`, `qprocessing-action-fields`
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
self.client.login(username=self.test_admin1.username, password=self.test_admin1.username)
|
|
61
|
+
|
|
62
|
+
qgs_alyer_id = 'points_aae45d3d_4911_445f_a6de_0e4ab724cd1b'
|
|
63
|
+
|
|
64
|
+
# Testing exception
|
|
65
|
+
# -----------------------------
|
|
66
|
+
# No layer id
|
|
67
|
+
url = reverse('qprocessing-action-fields', args=[self.project.instance.pk, 'no_layer_id'])
|
|
68
|
+
res = self.client.get(url)
|
|
69
|
+
self.assertEqual(res.status_code, 500)
|
|
70
|
+
|
|
71
|
+
jres = json.loads(res.content)
|
|
72
|
+
self.assertFalse(jres['result'])
|
|
73
|
+
self.assertEqual(jres['error'], {"code":"servererror","message":"A error server is occured!",
|
|
74
|
+
"data":"Layer matching query does not exist."})
|
|
75
|
+
|
|
76
|
+
# datatype empty
|
|
77
|
+
url = reverse('qprocessing-action-fields', args=[self.project.instance.pk, qgs_alyer_id])
|
|
78
|
+
res = self.client.get(f'{url}?datatype=')
|
|
79
|
+
self.assertEqual(res.status_code, 400)
|
|
80
|
+
|
|
81
|
+
jres = json.loads(res.content)
|
|
82
|
+
self.assertFalse(jres['result'])
|
|
83
|
+
self.assertEqual(jres['error'], {"code": "validation", "message": "Data are not correct or insufficent!",
|
|
84
|
+
"data": ["For datatype the admissible values are: string, numeric, datetime, "
|
|
85
|
+
"any"]})
|
|
86
|
+
|
|
87
|
+
# wrong datatype
|
|
88
|
+
url = reverse('qprocessing-action-fields', args=[self.project.instance.pk, qgs_alyer_id])
|
|
89
|
+
res = self.client.get(f'{url}?datatype=wrong')
|
|
90
|
+
self.assertEqual(res.status_code, 400)
|
|
91
|
+
|
|
92
|
+
jres = json.loads(res.content)
|
|
93
|
+
self.assertFalse(jres['result'])
|
|
94
|
+
self.assertEqual(jres['error'], {"code": "validation", "message": "Data are not correct or insufficent!",
|
|
95
|
+
"data": ["'wrong' is not a valid datatype, the admissible values are: string, "
|
|
96
|
+
"numeric, datetime, any"]})
|
|
97
|
+
|
|
98
|
+
# Testing filtering results
|
|
99
|
+
# -----------------------------------
|
|
100
|
+
# All fields: without `datatype` get parameter
|
|
101
|
+
|
|
102
|
+
url = reverse('qprocessing-action-fields', args=[self.project.instance.pk, qgs_alyer_id])
|
|
103
|
+
res = self.client.get(url)
|
|
104
|
+
self.assertEqual(res.status_code, 200)
|
|
105
|
+
|
|
106
|
+
qprj = get_qgs_project(self.project.instance.qgis_file.path)
|
|
107
|
+
qlayer = qprj.mapLayer(qgs_alyer_id)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
aspected_all = {
|
|
111
|
+
'result': True,
|
|
112
|
+
'fields': [{'key': f.displayName(), 'value':f.name()} for f in qlayer.fields()]
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
jres = json.loads(res.content)
|
|
116
|
+
self.assertEqual(jres, aspected_all)
|
|
117
|
+
|
|
118
|
+
# `datatype': string
|
|
119
|
+
url = reverse('qprocessing-action-fields', args=[self.project.instance.pk, qgs_alyer_id])
|
|
120
|
+
res = self.client.get(f'{url}?datatype=string')
|
|
121
|
+
self.assertEqual(res.status_code, 200)
|
|
122
|
+
|
|
123
|
+
aspected = {
|
|
124
|
+
'result': True,
|
|
125
|
+
'fields': [{'key': 'name', 'value': 'name'}]
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
jres = json.loads(res.content)
|
|
129
|
+
self.assertEqual(jres, aspected)
|
|
130
|
+
|
|
131
|
+
# `datatype': numeric
|
|
132
|
+
url = reverse('qprocessing-action-fields', args=[self.project.instance.pk, qgs_alyer_id])
|
|
133
|
+
res = self.client.get(f'{url}?datatype=numeric')
|
|
134
|
+
self.assertEqual(res.status_code, 200)
|
|
135
|
+
|
|
136
|
+
aspected = {
|
|
137
|
+
'result': True,
|
|
138
|
+
'fields': [
|
|
139
|
+
{'key': 'fid', 'value': 'fid'},
|
|
140
|
+
{'key': 'value', 'value': 'value'}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
jres = json.loads(res.content)
|
|
145
|
+
self.assertEqual(jres, aspected)
|
|
146
|
+
|
|
147
|
+
# `datatype': datetime
|
|
148
|
+
url = reverse('qprocessing-action-fields', args=[self.project.instance.pk, qgs_alyer_id])
|
|
149
|
+
res = self.client.get(f'{url}?datatype=datetime')
|
|
150
|
+
self.assertEqual(res.status_code, 200)
|
|
151
|
+
|
|
152
|
+
aspected = {
|
|
153
|
+
'result': True,
|
|
154
|
+
'fields': []
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
jres = json.loads(res.content)
|
|
158
|
+
self.assertEqual(jres, aspected)
|
|
159
|
+
|
|
160
|
+
# `datatype': any
|
|
161
|
+
url = reverse('qprocessing-action-fields', args=[self.project.instance.pk, qgs_alyer_id])
|
|
162
|
+
res = self.client.get(f'{url}?datatype=any')
|
|
163
|
+
self.assertEqual(res.status_code, 200)
|
|
164
|
+
|
|
165
|
+
jres = json.loads(res.content)
|
|
166
|
+
self.assertEqual(jres, aspected_all)
|
|
167
|
+
|
|
168
|
+
self.client.logout()
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|