Skip to content

Commit

Permalink
tests(plsql): add new tests for some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nperez-bgeo committed Aug 20, 2024
1 parent b65e4f7 commit 1264ea4
Show file tree
Hide file tree
Showing 59 changed files with 1,833 additions and 38 deletions.
35 changes: 35 additions & 0 deletions test/plsql/ud/test_gw_fct_config_mapzones.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
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 2 test
SELECT plan(2);

-- 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',
'Accepted',
'Check if gw_fct_getprofile 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',
'Accepted',
'Check if gw_fct_getprofile with parameters returns status "Accepted"'
);

-- Finish the test
SELECT finish();

ROLLBACK;
12 changes: 10 additions & 2 deletions test/plsql/ud/test_gw_fct_getcatalog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@ SELECT is (
"tabName":"data", "editable":"TRUE"}, "feature":{"feature_type":"CONDUIT"}, "data":{"filterFields":{}, "pageInfo":{},
"fields":{"matcat_id":"", "shape":"", "geom1":""}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getcatalog returns status "Accepted"'
'Check if gw_fct_getcatalog --> "feature_type":"CONDUIT" returns status "Accepted"'
);

SELECT is (
(gw_fct_getcatalog($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{"formName":"upsert_catalog_node",
"tabName":"data", "editable":"TRUE"}, "feature":{"feature_type":"CIRC_MANHOLE"}, "data":{"filterFields":{}, "pageInfo":{},
"fields":{"matcat_id":"", "shape":"", "geom1":""}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getcatalog --> "feature_type":"CIRC_MANHOLE" returns status "Accepted"'
);

-- Finish the test
SELECT finish();

ROLLBACK;
ROLLBACK;
27 changes: 27 additions & 0 deletions test/plsql/ud/test_gw_fct_getcatfeaturevalues.sql
Original file line number Diff line number Diff line change
@@ -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_getcatfeaturevalues($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
"feature":{}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getcatfeaturevalues returns status "Accepted"'
);

-- Finish the test
SELECT finish();

ROLLBACK;
37 changes: 37 additions & 0 deletions test/plsql/ud/test_gw_fct_getconfig.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
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 2 test
SELECT plan(2);

-- Extract and test the "status" field from the function's JSON response
SELECT is (
(gw_fct_getconfig($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{"formName":"epaoptions"},
"feature":{}, "data":{"filterFields":{}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getconfig --> "formName":"epaoptions" returns status "Accepted"'
);

SELECT is (
(gw_fct_getconfig($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{"formName":"config"},
"feature":{}, "data":{"filterFields":{}, "pageInfo":{}, "list_layers_name":"{Node, Connec, Gully, Arc, Link, Node polygon,
Gully polygon, Connec polygon, Dimensioning, Element, Municipality, Streetaxis, Plot}", "list_tables_name":"{v_edit_node,
v_edit_connec, v_edit_gully, v_edit_arc, v_edit_link, ve_pol_node, ve_pol_gully, ve_pol_connec, v_edit_dimensions, v_edit_element,
ext_municipality, v_ext_streetaxis, v_ext_plot}"}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getconfig --> "formName":"config" returns status "Accepted"'
);

-- Finish the test
SELECT finish();

ROLLBACK;
28 changes: 28 additions & 0 deletions test/plsql/ud/test_gw_fct_getdimensioning.sql
Original file line number Diff line number Diff line change
@@ -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_getdimensioning($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{},
"data":{"filterFields":{}, "pageInfo":{}, "coordinates":{"x1":418858.6453457861, "y1":4576610.154527264, "x2":418864.97096759855,
"y2":4576605.676899829}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getdimensioning returns status "Accepted"'
);

-- Finish the test
SELECT finish();

ROLLBACK;
27 changes: 27 additions & 0 deletions test/plsql/ud/test_gw_fct_getfeaturerelation.sql
Original file line number Diff line number Diff line change
@@ -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_getfeaturerelation($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{"type":"ARC"},
"data":{"filterFields":{}, "pageInfo":{}, "feature_id":"160"}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getfeaturerelation returns status "Accepted"'
);

-- Finish the test
SELECT finish();

ROLLBACK;
24 changes: 14 additions & 10 deletions test/plsql/ud/test_gw_fct_getinfofromid.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,51 @@ SET client_min_messages TO WARNING;

SET search_path = "SCHEMA_NAME", public, pg_catalog;

SELECT plan(1);
SELECT ok(1=1, 'One equals one');

-- TODO: Add test for gw_fct_getinfofromid
-- -- Plan for 1 test
-- SELECT plan(5);
-- -- Plan for 6 test
-- SELECT plan(6);

-- -- Extract and test the "status" field from the function's JSON response
-- SELECT is(
-- (gw_fct_getinfofromid($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
-- "feature":{"tableName":"v_edit_node", "id":"89"}, "data":{"filterFields":{}, "pageInfo":{}, "addSchema":""}}$$)::JSON)->>'status',
-- 'Accepted',
-- 'Check if gw_fct_getinfofromid returns status "Accepted"'
-- 'Check if gw_fct_getinfofromid tableName --> v_edit_node returns status "Accepted"'
-- );

-- SELECT is(
-- (gw_fct_getinfofromid($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
-- "feature":{"tableName":"v_edit_connec", "id":"3149"}, "data":{"filterFields":{}, "pageInfo":{}, "addSchema":""}}$$)::JSON)->>'status',
-- 'Accepted',
-- 'Check if gw_fct_getinfofromid returns status "Accepted"'
-- 'Check if gw_fct_getinfofromid tableName --> v_edit_connec returns status "Accepted"'
-- );

-- SELECT is(
-- (gw_fct_getinfofromid($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
-- "feature":{"tableName":"v_edit_gully", "id":"30087"}, "data":{"filterFields":{}, "pageInfo":{}, "addSchema":""}}$$)::JSON)->>'status',
-- 'Accepted',
-- 'Check if gw_fct_getinfofromid returns status "Accepted"'
-- 'Check if gw_fct_getinfofromid tableName --> v_edit_gully returns status "Accepted"'
-- );

-- SELECT is(
-- (gw_fct_getinfofromid($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
-- "feature":{"tableName":"v_edit_arc", "id":"204"}, "data":{"filterFields":{}, "pageInfo":{}, "addSchema":""}}$$)::JSON)->>'status',
-- 'Accepted',
-- 'Check if gw_fct_getinfofromid returns status "Accepted"'
-- 'Check if gw_fct_getinfofromid tableName --> v_edit_arc returns status "Accepted"'
-- );

-- SELECT is(
-- (gw_fct_getinfofromid($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
-- "feature":{"tableName":"v_edit_link", "id":"550"}, "data":{"filterFields":{}, "pageInfo":{}, "addSchema":""}}$$)::JSON)->>'status',
-- 'Accepted',
-- 'Check if gw_fct_getinfofromid returns status "Accepted"'
-- 'Check if gw_fct_getinfofromid tableName --> v_edit_link returns status "Accepted"'
-- );

-- 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 returns status "Accepted"'
-- );

-- Finish the test
Expand Down
31 changes: 24 additions & 7 deletions test/plsql/ud/test_gw_fct_getlist.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,67 @@ SET client_min_messages TO WARNING;

SET search_path = "SCHEMA_NAME", public, pg_catalog;

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

-- Extract and test the "status" field from the function's JSON response
SELECT is (
(gw_fct_getlist($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{"formName":"", "tabName":"epa",
"widgetname":"tab_epa_tbl_inp_junction", "formtype":"form_feature"}, "feature":{"tableName":"tbl_inp_dscenario_junction",
"idName":"node_id", "id":"74"}, "data":{"filterFields":{"node_id":{"value":"74","filterSign":"="}}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getlist returns status "Accepted"'
'Check if gw_fct_getlist --> "tableName":"tbl_inp_dscenario_junction" returns status "Accepted"'
);

SELECT is (
(gw_fct_getlist($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{"formName":"", "tabName":"connections",
"widgetname":"tab_connections_tbl_downstream", "formtype":"form_feature"}, "feature":{"tableName":"tbl_connection_downstream",
"idName":"node_id", "id":"74"}, "data":{"filterFields":{"node_id":{"value":"74","filterSign":"="}}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getlist returns status "Accepted"'
'Check if gw_fct_getlist --> "tableName":"tbl_connection_downstream" returns status "Accepted"'
);

SELECT is (
(gw_fct_getlist($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{"formName":"", "tabName":"elements",
"widgetname":"tab_elements_tbl_elements", "formtype":"form_feature"}, "feature":{"tableName":"tbl_element_x_node",
"idName":"node_id", "id":"74"}, "data":{"filterFields":{"node_id":{"value":"74","filterSign":"="}}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getlist returns status "Accepted"'
'Check if gw_fct_getlist --> "tableName":"tbl_element_x_node" returns status "Accepted"'
);

SELECT is (
(gw_fct_getlist($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{"formName":"", "tabName":"event",
"widgetname":"tab_event_tbl_event_cf", "formtype":"form_feature"}, "feature":{"tableName":"tbl_event_x_node", "idName":"node_id",
"id":"74"}, "data":{"filterFields":{"node_id":{"value":"74","filterSign":"="}}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getlist returns status "Accepted"'
'Check if gw_fct_getlist --> "tableName":"tbl_event_x_node" returns status "Accepted"'
);

SELECT is (
(gw_fct_getlist($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{"formName":"", "tabName":"documents",
"widgetname":"tab_documents_tbl_documents", "formtype":"form_feature"}, "feature":{"tableName":"tbl_doc_x_node", "idName":"node_id",
"id":"74"}, "data":{"filterFields":{"node_id":{"value":"74","filterSign":"="}}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getlist returns status "Accepted"'
'Check if gw_fct_getlist --> "tableName":"tbl_doc_x_node" returns status "Accepted"'
);

SELECT is (
(gw_fct_getlist($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
"feature":{"tableName":"v_edit_cat_hydrology"}, "data":{"filterFields":{"limit": -1, "name":
{"filterSign":"ILIKE", "value":""}, "active": {"filterSign":"=", "value":"true"}}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getlist --> "tableName":"v_edit_cat_hydrology" returns status "Accepted"'
);

SELECT is (
(gw_fct_getlist($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{"tableName":"cat_work"},
"data":{"filterFields":{"limit": -1, "id": {"filterSign":"ILIKE", "value":""}}, "pageInfo":{}}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getlist --> "tableName":"cat_work" returns status "Accepted"'
);



-- Finish the test
SELECT finish();

Expand Down
27 changes: 27 additions & 0 deletions test/plsql/ud/test_gw_fct_getprint.sql
Original file line number Diff line number Diff line change
@@ -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_getprint($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{}, "feature":{},
"data":{"filterFields":{}, "pageInfo":{}, "composers":"{composer_plan}"}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getprint returns status "Accepted"'
);

-- Finish the test
SELECT finish();

ROLLBACK;
35 changes: 35 additions & 0 deletions test/plsql/ud/test_gw_fct_getprocess.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
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_getprocess($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
"feature":{}, "data":{"filterFields":{}, "pageInfo":{}, "functionId":3100}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getprocess --> "functionId":3100 returns status "Accepted"'
);

SELECT is (
(gw_fct_getprocess($${"client":{"device":4, "lang":"es_ES", "infoType":1, "epsg":25831}, "form":{},
"feature":{}, "data":{"filterFields":{}, "pageInfo":{}, "functionId":"2670"}}$$)::JSON)->>'status',
'Accepted',
'Check if gw_fct_getprocess --> "functionId":"2670" returns status "Accepted"'
);


-- Finish the test
SELECT finish();

ROLLBACK;
Loading

0 comments on commit 1264ea4

Please sign in to comment.