From b041d3c5f4ad33825387bb7cf7c70a408ce47e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20P=C3=A9rez?= Date: Tue, 27 Aug 2024 13:27:40 +0200 Subject: [PATCH] tests(plsql): add new functions --- test/plsql/ud/test_gw_fct_getinfofromid.sql | 26 +++++++++++- test/plsql/ud/test_gw_fct_gettypeahead.sql | 30 ++++++++++++++ .../ud/test_gw_fct_om_visit_multiplier.sql | 27 +++++++++++++ test/plsql/ud/test_gw_fct_rpt2pg_main.sql | 27 +++++++++++++ .../ud/test_gw_fct_setfeaturereplace.sql | 28 +++++++++++++ test/plsql/ws/test_gw_fct_getgraphconfig.sql | 37 +++++++++++++---- test/plsql/ws/test_gw_fct_getinfofromid.sql | 40 ++++++++++++++++++- .../ws/test_gw_fct_om_visit_multiplier.sql | 27 +++++++++++++ test/plsql/ws/test_gw_fct_rpt2pg_main.sql | 27 +++++++++++++ .../plsql/ws/test_gw_fct_set_rpt_archived.sql | 27 +++++++++++++ .../ws/test_gw_fct_setfeaturereplace.sql | 28 +++++++++++++ 11 files changed, 312 insertions(+), 12 deletions(-) create mode 100644 test/plsql/ud/test_gw_fct_gettypeahead.sql create mode 100644 test/plsql/ud/test_gw_fct_om_visit_multiplier.sql create mode 100644 test/plsql/ud/test_gw_fct_rpt2pg_main.sql create mode 100644 test/plsql/ud/test_gw_fct_setfeaturereplace.sql create mode 100644 test/plsql/ws/test_gw_fct_om_visit_multiplier.sql create mode 100644 test/plsql/ws/test_gw_fct_rpt2pg_main.sql create mode 100644 test/plsql/ws/test_gw_fct_set_rpt_archived.sql create mode 100644 test/plsql/ws/test_gw_fct_setfeaturereplace.sql diff --git a/test/plsql/ud/test_gw_fct_getinfofromid.sql b/test/plsql/ud/test_gw_fct_getinfofromid.sql index b68513532e..af40570a1f 100644 --- a/test/plsql/ud/test_gw_fct_getinfofromid.sql +++ b/test/plsql/ud/test_gw_fct_getinfofromid.sql @@ -10,8 +10,8 @@ SET client_min_messages TO WARNING; SET search_path = "SCHEMA_NAME", public, pg_catalog; --- Plan for 6 test -SELECT plan(6); +-- Plan for 9 test +SELECT plan(9); -- Extract and test the "status" field from the function's JSON response SELECT is( @@ -53,9 +53,31 @@ SELECT is( (gw_fct_getinfofromid($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{"tableName":"v_edit_drainzone", "id": "0"}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', 'Accepted', + 'Check if gw_fct_getinfofromid tableName --> v_edit_drainzone with id returns status "Accepted"' +); + +SELECT is( + (gw_fct_getinfofromid($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"tableName":"v_edit_drainzone"}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', 'Check if gw_fct_getinfofromid tableName --> v_edit_drainzone returns status "Accepted"' ); +SELECT is( + (gw_fct_getinfofromid($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"tableName":"inp_dscenario_outfall", "id": "1, 18888"}, + "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getinfofromid tableName --> inp_dscenario_outfall returns status "Accepted"' +); + +SELECT is( + (gw_fct_getinfofromid($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"tableName":"v_edit_cat_dscenario", "id":"1"}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getinfofromid tableName --> v_edit_cat_dscenario returns status "Accepted"' +); + -- Finish the test SELECT * FROM finish(); diff --git a/test/plsql/ud/test_gw_fct_gettypeahead.sql b/test/plsql/ud/test_gw_fct_gettypeahead.sql new file mode 100644 index 0000000000..43f7d9e0b2 --- /dev/null +++ b/test/plsql/ud/test_gw_fct_gettypeahead.sql @@ -0,0 +1,30 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ +BEGIN; + +-- Suppress NOTICE messages +SET client_min_messages TO WARNING; + +SET search_path = "SCHEMA_NAME", public, pg_catalog; + +-- Plan for 1 test +SELECT plan(1); + +-- Extract and test the "status" field from the function's JSON response +SELECT is ( + (gw_fct_gettypeahead($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{}, "data":{"filterFields":{}, "pageInfo":{}, + "queryText":"SELECT id, id as idval FROM cat_node WHERE id IS NOT NULL AND active IS TRUE ", + "queryTextFilter":" AND cat_node.node_type IS NULL OR cat_node.node_type", "parentId":"node_type", + "parentValue":"CIRC_MANHOLE", "textToSearch":"1"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_gettypeahead returns status "Accepted"' +); + +-- Finish the test +SELECT finish(); + +ROLLBACK; diff --git a/test/plsql/ud/test_gw_fct_om_visit_multiplier.sql b/test/plsql/ud/test_gw_fct_om_visit_multiplier.sql new file mode 100644 index 0000000000..74b7717936 --- /dev/null +++ b/test/plsql/ud/test_gw_fct_om_visit_multiplier.sql @@ -0,0 +1,27 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ +BEGIN; + +-- Suppress NOTICE messages +SET client_min_messages TO WARNING; + +SET search_path = "SCHEMA_NAME", public, pg_catalog; + +-- Plan for 1 test +SELECT plan(1); + +-- Extract and test the "status" field from the function's JSON response +SELECT is( + (gw_fct_om_visit_multiplier($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"id":"1995"}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_om_visit_multiplier returns status "Accepted"' +); + +-- Finish the test +SELECT finish(); + +ROLLBACK; diff --git a/test/plsql/ud/test_gw_fct_rpt2pg_main.sql b/test/plsql/ud/test_gw_fct_rpt2pg_main.sql new file mode 100644 index 0000000000..54475e1756 --- /dev/null +++ b/test/plsql/ud/test_gw_fct_rpt2pg_main.sql @@ -0,0 +1,27 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ +BEGIN; + +-- Suppress NOTICE messages +SET client_min_messages TO WARNING; + +SET search_path = "SCHEMA_NAME", public, pg_catalog; + +-- Plan for 1 test +SELECT plan(1); + +-- Extract and test the "status" field from the function's JSON response +SELECT is( + (gw_fct_rpt2pg_main($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, + "data":{"filterFields":{}, "pageInfo":{}, "step":"2", "resultId":"test"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_rpt2pg_main returns status "Accepted"' +); + +-- Finish the test +SELECT finish(); + +ROLLBACK; diff --git a/test/plsql/ud/test_gw_fct_setfeaturereplace.sql b/test/plsql/ud/test_gw_fct_setfeaturereplace.sql new file mode 100644 index 0000000000..e62588bd6d --- /dev/null +++ b/test/plsql/ud/test_gw_fct_setfeaturereplace.sql @@ -0,0 +1,28 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ +BEGIN; + +-- Suppress NOTICE messages +SET client_min_messages TO WARNING; + +SET search_path = "SCHEMA_NAME", public, pg_catalog; + +-- Plan for 1 test +SELECT plan(1); + +-- Extract and test the "status" field from the function's JSON response +SELECT is( + (gw_fct_setfeaturereplace($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, "feature":{"type":"arc"}, + "data":{"filterFields":{}, "pageInfo":{}, "old_feature_id":"154", "feature_type_new":"WACCEL", "featurecat_id":"WACCEL-CC020", + "workcat_id_end":"work1", "enddate":"2024-08-27", "keep_elements":"False", "keep_epa_values":"True"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_setfeaturereplace returns status "Accepted"' +); + +-- Finish the test +SELECT finish(); + +ROLLBACK; diff --git a/test/plsql/ws/test_gw_fct_getgraphconfig.sql b/test/plsql/ws/test_gw_fct_getgraphconfig.sql index 29b8c1d0c8..17e432f3a2 100644 --- a/test/plsql/ws/test_gw_fct_getgraphconfig.sql +++ b/test/plsql/ws/test_gw_fct_getgraphconfig.sql @@ -10,22 +10,43 @@ 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_getgraphconfig($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, - "pageInfo":{}, "context":"NETSCENARIO", "mapzone": "dma", "mapzoneId": "2", "netscenarioId": 1}}$$)::JSON)->>'status', + (gw_fct_getgraphconfig($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, + "data":{"filterFields":{}, "pageInfo":{}, "context":"OPERATIVE", "mapzone": "sector", "mapzoneId": "1"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getgraphconfig --> "context":"OPERATIVE" and "mapzone": "sector" returns status "Accepted"' +); + +SELECT is ( + (gw_fct_getgraphconfig($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{}, "data":{"filterFields":{}, "pageInfo":{}, "context":"OPERATIVE", "mapzone": "presszone"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getgraphconfig --> "context":"OPERATIVE" and "mapzone": "presszone" returns status "Accepted"' +); + +SELECT is ( + (gw_fct_getgraphconfig($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{}, "data":{"filterFields":{}, "pageInfo":{}, "context":"OPERATIVE", "mapzone": "dma"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getgraphconfig --> "context":"OPERATIVE" and "mapzone": "dma" returns status "Accepted"' +); + +SELECT is ( + (gw_fct_getgraphconfig($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{}, "data":{"filterFields":{}, "pageInfo":{}, "context":"NETSCENARIO", "mapzone": "presszone"}}$$)::JSON)->>'status', 'Accepted', - 'Check if gw_fct_getgraphconfig --> "context":"NETSCENARIO" returns status "Accepted"' + 'Check if gw_fct_getgraphconfig --> "context":"NETSCENARIO" and "mapzone": "presszone" returns status "Accepted"' ); SELECT is ( - (gw_fct_getstylemapzones($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, - "data":{"filterFields":{}, "pageInfo":{}, "mapzones":""}}$$)::JSON)->>'status', + (gw_fct_getgraphconfig($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, "data":{"filterFields":{}, + "pageInfo":{}, "context":"NETSCENARIO", "mapzone": "dma", "mapzoneId": "2", "netscenarioId": 1}}$$)::JSON)->>'status', 'Accepted', - 'Check if gw_fct_getgraphconfig returns status "Accepted"' + 'Check if gw_fct_getgraphconfig --> "context":"NETSCENARIO" and "mapzone": "dma" returns status "Accepted"' ); -- Finish the test diff --git a/test/plsql/ws/test_gw_fct_getinfofromid.sql b/test/plsql/ws/test_gw_fct_getinfofromid.sql index 05a7acd00a..f193baf0c3 100644 --- a/test/plsql/ws/test_gw_fct_getinfofromid.sql +++ b/test/plsql/ws/test_gw_fct_getinfofromid.sql @@ -10,8 +10,8 @@ SET client_min_messages TO WARNING; SET search_path = "SCHEMA_NAME", public, pg_catalog; --- Plan for 5 test -SELECT plan(5); +-- Plan for 10 test +SELECT plan(10); -- Extract and test the "status" field from the function's JSON response SELECT is( @@ -49,6 +49,42 @@ SELECT is( 'Check if gw_fct_getinfofromid --> "tableName":"plan_netscenario_dma" returns status "Accepted"' ); +SELECT is( + (gw_fct_getinfofromid($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"tableName":"v_edit_plan_netscenario_presszone", "isLayer":true}, + "data":{"filterFields":{}, "pageInfo":{}, "infoType":"full"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getinfofromid --> "tableName":"v_edit_plan_netscenario_presszone" returns status "Accepted"' +); + +SELECT is( + (gw_fct_getinfofromid($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"tableName":"v_edit_sector"}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getinfofromid --> "tableName":"v_edit_sector" returns status "Accepted"' +); + +SELECT is( + (gw_fct_getinfofromid($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"tableName":"v_edit_sector", "id": "2"}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getinfofromid --> "tableName":"v_edit_sector" with id returns status "Accepted"' +); + +SELECT is( + (gw_fct_getinfofromid($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"tableName":"inp_dscenario_demand", "id": "1, 113959"}, + "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getinfofromid --> "tableName":"inp_dscenario_demand" with id returns status "Accepted"' +); + +SELECT is( + (gw_fct_getinfofromid($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"tableName":"v_edit_cat_dscenario", "id":"1"}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_getinfofromid --> "tableName":"v_edit_cat_dscenario" with id returns status "Accepted"' +); -- Finish the test SELECT finish(); diff --git a/test/plsql/ws/test_gw_fct_om_visit_multiplier.sql b/test/plsql/ws/test_gw_fct_om_visit_multiplier.sql new file mode 100644 index 0000000000..2e3302304d --- /dev/null +++ b/test/plsql/ws/test_gw_fct_om_visit_multiplier.sql @@ -0,0 +1,27 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ +BEGIN; + +-- Suppress NOTICE messages +SET client_min_messages TO WARNING; + +SET search_path = "SCHEMA_NAME", public, pg_catalog; + +-- Plan for 1 test +SELECT plan(1); + +-- Extract and test the "status" field from the function's JSON response +SELECT is( + (gw_fct_om_visit_multiplier($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, + "feature":{"id":"990"}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_om_visit_multiplier returns status "Accepted"' +); + +-- Finish the test +SELECT finish(); + +ROLLBACK; diff --git a/test/plsql/ws/test_gw_fct_rpt2pg_main.sql b/test/plsql/ws/test_gw_fct_rpt2pg_main.sql new file mode 100644 index 0000000000..75c42dcaad --- /dev/null +++ b/test/plsql/ws/test_gw_fct_rpt2pg_main.sql @@ -0,0 +1,27 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ +BEGIN; + +-- Suppress NOTICE messages +SET client_min_messages TO WARNING; + +SET search_path = "SCHEMA_NAME", public, pg_catalog; + +-- Plan for 1 test +SELECT plan(1); + +-- Extract and test the "status" field from the function's JSON response +SELECT is( + (gw_fct_rpt2pg_main($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, + "data":{"filterFields":{}, "pageInfo":{}, "step":"2", "resultId":"test0"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_rpt2pg_main returns status "Accepted"' +); + +-- Finish the test +SELECT finish(); + +ROLLBACK; diff --git a/test/plsql/ws/test_gw_fct_set_rpt_archived.sql b/test/plsql/ws/test_gw_fct_set_rpt_archived.sql new file mode 100644 index 0000000000..d3da1ffac9 --- /dev/null +++ b/test/plsql/ws/test_gw_fct_set_rpt_archived.sql @@ -0,0 +1,27 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ +BEGIN; + +-- Suppress NOTICE messages +SET client_min_messages TO WARNING; + +SET search_path = "SCHEMA_NAME", public, pg_catalog; + +-- Plan for 1 test +SELECT plan(1); + +-- Extract and test the "status" field from the function's JSON response +SELECT is( + (gw_fct_set_rpt_archived($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, "feature":{}, + "data":{"filterFields":{}, "pageInfo":{}, "result_id":"test0", "action": "ARCHIVE"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_set_rpt_archived returns status "Accepted"' +); + +-- Finish the test +SELECT finish(); + +ROLLBACK; diff --git a/test/plsql/ws/test_gw_fct_setfeaturereplace.sql b/test/plsql/ws/test_gw_fct_setfeaturereplace.sql new file mode 100644 index 0000000000..0f036b8b76 --- /dev/null +++ b/test/plsql/ws/test_gw_fct_setfeaturereplace.sql @@ -0,0 +1,28 @@ +/* +This file is part of Giswater 3 +The program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +This version of Giswater is provided by Giswater Association +*/ +BEGIN; + +-- Suppress NOTICE messages +SET client_min_messages TO WARNING; + +SET search_path = "SCHEMA_NAME", public, pg_catalog; + +-- Plan for 1 test +SELECT plan(1); + +-- Extract and test the "status" field from the function's JSON response +SELECT is( + (gw_fct_setfeaturereplace($${"client":{"device":4, "lang":"", "infoType":1, "epsg":25831}, "form":{}, "feature":{"type":"arc"}, + "data":{"filterFields":{}, "pageInfo":{}, "old_feature_id":"113854", "feature_type_new":"PIPE", "featurecat_id":"FD150", + "workcat_id_end":"work1", "enddate":"2017-12-06", "keep_elements":"False", "keep_epa_values":"False"}}$$)::JSON)->>'status', + 'Accepted', + 'Check if gw_fct_setfeaturereplace returns status "Accepted"' +); + +-- Finish the test +SELECT finish(); + +ROLLBACK;