Skip to content

Commit

Permalink
tests(plsql): add gw_fct_config_mapzones test function
Browse files Browse the repository at this point in the history
  • Loading branch information
nperez-bgeo committed Aug 22, 2024
1 parent 9bc1db6 commit 15e70a9
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 12 deletions.
43 changes: 34 additions & 9 deletions test/plsql/ud/test_gw_fct_config_mapzones.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,48 @@ SET client_min_messages TO WARNING;

SET search_path = "SCHEMA_NAME", public, pg_catalog;

-- Plan for 2 test
SELECT plan(2);
-- Plan for 5 test
SELECT plan(5);

-- Extract and test the "status" field from the function's JSON response
SELECT is (
(gw_fct_getprofile($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{},
"data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status',
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "UPDATE", "configZone": "drainzone", "mapzoneId": "-1",
"config": {"use":[{"nodeParent":""}], "ignore":[], "forceClosed":[]}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getprofile returns status "Accepted"'
'Check if gw_fct_config_mapzones with action "UPDATE" returns status "Accepted"'
);

SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{},
"data":{"filterFields":{}, "pageInfo":{}, "parameters": {"action": "UPDATE", "configZone": "drainzone",
"mapzoneId": "-1", "config": {"use":[{"nodeParent":""}], "ignore":[], "forceClosed":[]}}}}$$)::JSON)->>'status',
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "ADD", "configZone": "drainzone", "mapzoneId": "-1", "nodeParent": "82", "toArc": [], "config": {"use":[{"nodeParent":""}], "ignore":[],
"forceClosed":[]}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getprofile with parameters returns status "Accepted"'
'Check if gw_fct_config_mapzones with action "ADD" and 4th parameter is "nodeParent" returns status "Accepted"'
);

SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "ADD", "configZone": "drainzone", "mapzoneId": "-1", "forceClosed": ["82"], "config": {"use": [{"nodeParent": "82"}], "ignore": [],
"forceClosed": []}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_config_mapzones with action "ADD" and 4th parameter is "forceClosed" returns status "Accepted"'
);

SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "REMOVE", "configZone": "drainzone", "mapzoneId": "-1", "nodeParent": "82", "config": {"use": [{"nodeParent": "82"}], "ignore": [],
"forceClosed": []}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_config_mapzones with action "REMOVE" and 4th parameter is "nodeParent" returns status "Accepted"'
);

SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "REMOVE", "configZone": "drainzone", "mapzoneId": "-1", "forceClosed": ["82"],
"config": {"use": [{"nodeParent": "82"}], "ignore": [], "forceClosed": [82]}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_config_mapzones with action "REMOVE" and 4th parameter is "forceClosed" returns status "Accepted"'
);

-- Finish the test
Expand Down
38 changes: 35 additions & 3 deletions test/plsql/ws/test_gw_fct_config_mapzones.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,47 @@ SET client_min_messages TO WARNING;

SET search_path = "SCHEMA_NAME", public, pg_catalog;

-- Plan for 1 test
SELECT plan(1);
-- Plan for 5 test
SELECT plan(5);

-- Extract and test the "status" field from the function's JSON response
SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "UPDATE", "configZone": "dma", "mapzoneId": "2", "config": {"use":[], "ignore":[], "forceClosed":[]}, "netscenarioId": 1}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_config_mapzones returns status "Accepted"'
'Check if gw_fct_config_mapzones with action "UPDATE" returns status "Accepted"'
);

SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "ADD", "configZone": "sector", "mapzoneId": "1", "nodeParent": "1010", "toArc": ["2018"], "config": {"use": [{"toArc": [2207], "nodeParent": "1097"}],
"ignore": [], "forceClosed": [1010]}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_config_mapzones with action "ADD" and 4th parameter is "nodeParent" returns status "Accepted"'
);

SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "ADD", "configZone": "sector", "mapzoneId": "1", "forceClosed": ["1010"], "config": {"use": [{"toArc": [2207], "nodeParent": "1097"},
{"toArc": [2018], "nodeParent": "1010"}], "ignore": [], "forceClosed": [1010]}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_config_mapzones with action "ADD" and 4th parameter is "forceClosed" returns status "Accepted"'
);

SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "REMOVE", "configZone": "sector", "mapzoneId": "1", "nodeParent": "1010", "config": {"use": [{"toArc": [2207], "nodeParent": "1097"},
{"toArc": [2018], "nodeParent": "1010"}], "ignore": [], "forceClosed": [1010]}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_config_mapzones with action "REMOVE" and 4th parameter is "nodeParent" returns status "Accepted"'
);

SELECT is (
(gw_fct_config_mapzones($${"client":{"device":4, "lang":"NULL", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, "pageInfo":{},
"parameters": {"action": "REMOVE", "configZone": "sector", "mapzoneId": "1", "forceClosed": ["1010"], "config": {"use": [{"toArc": [2207], "nodeParent": "1097"}],
"ignore": [], "forceClosed": [1010]}}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_config_mapzones with action "REMOVE" and 4th parameter is "forceClosed" returns status "Accepted"'
);

-- Finish the test
Expand Down

0 comments on commit 15e70a9

Please sign in to comment.