Skip to content

Commit

Permalink
tests(upsert): add arc and ve_arc
Browse files Browse the repository at this point in the history
  • Loading branch information
danimarinBG committed Aug 22, 2024
1 parent 470bf89 commit 9bc1db6
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/upsert/ws/test_arc.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
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;

SELECT plan(6);

-- arc -> pipe
-- initial data is prepared before proceeding with the test
INSERT INTO ve_node_air_valve
(node_id, code, elevation, "depth", node_type, sys_type, nodecat_id, cat_matcat_id, cat_pnom, cat_dnom, cat_dint, epa_type, state, state_type, expl_id, macroexpl_id, sector_id, sector_name, macrosector_id, sector_type, presszone_id, preszone_name, presszone_type, presszone_head, dma_id, dma_name, dma_type, macrodma_id, dqa_id, dqa_name, dqa_type, macrodqa_id, arc_id, parent_id, annotation, observ, "comment", staticpressure, soilcat_id, function_type, category_type, fluid_type, location_type, workcat_id, workcat_id_end, workcat_id_plan, builtdate, enddate, buildercat_id, ownercat_id, muni_id, postcode, district_id, streetname, postnumber, postcomplement, streetname2, postnumber2, postcomplement2, region_id, province_id, descript, svg, rotation, link, verified, undelete, "label", label_x, label_y, label_rotation, publish, inventory, hemisphere, num_value, adate, adescript, accessibility, dma_style, presszone_style, asset_id, om_state, conserv_state, access_type, placement_type, expl_id2, is_operative, brand_id, model_id, serial_number, minsector_id, macrominsector_id, demand_max, demand_min, demand_avg, press_max, press_min, press_avg, head_max, head_min, head_avg, quality_max, quality_min, quality_avg, tstamp, insert_user, lastupdate, lastupdate_user, the_geom, inp_type, closed, broken, buried, irrigation_indicator, pression_entry, pression_exit, depth_valveshaft, regulator_situation, regulator_location, regulator_observ, lin_meters, exit_type, exit_code, drive_type, cat_valve2, ordinarystatus, shutter, brand2, model2, valve_type, to_arc, active, airvalve_param_1, airvalve_param_2)
VALUES('-902', '-902', 32.8100, NULL, 'AIR_VALVE', 'VALVE', 'AIR VALVE DN50', 'FD', '16', '50', NULL, 'UNDEFINED', 1, 2, 2, 1, 5, 'sector2-1d', 2, 'DISTRIBUTION', '3', 'pzone1-1d', NULL, NULL, 3, 'dma2-1d', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'soil1', NULL, NULL, NULL, NULL, 'work1', NULL, NULL, '2024-08-22', NULL, NULL, 'owner1', 2, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, '', '1', NULL, NULL, NULL, NULL, NULL, true, true, NULL, NULL, NULL, NULL, NULL, '204,235,197', '204,235,197', NULL, NULL, NULL, NULL, NULL, NULL, true, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-08-22 17:00:13.000', 'postgres', '2024-08-22 17:00:13.000', 'postgres', 'SRID=25831;POINT (418474.19510507485 4577983.667174499)'::public.geometry, NULL, false, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL);
INSERT INTO ve_node_air_valve
(node_id, code, elevation, "depth", node_type, sys_type, nodecat_id, cat_matcat_id, cat_pnom, cat_dnom, cat_dint, epa_type, state, state_type, expl_id, macroexpl_id, sector_id, sector_name, macrosector_id, sector_type, presszone_id, preszone_name, presszone_type, presszone_head, dma_id, dma_name, dma_type, macrodma_id, dqa_id, dqa_name, dqa_type, macrodqa_id, arc_id, parent_id, annotation, observ, "comment", staticpressure, soilcat_id, function_type, category_type, fluid_type, location_type, workcat_id, workcat_id_end, workcat_id_plan, builtdate, enddate, buildercat_id, ownercat_id, muni_id, postcode, district_id, streetname, postnumber, postcomplement, streetname2, postnumber2, postcomplement2, region_id, province_id, descript, svg, rotation, link, verified, undelete, "label", label_x, label_y, label_rotation, publish, inventory, hemisphere, num_value, adate, adescript, accessibility, dma_style, presszone_style, asset_id, om_state, conserv_state, access_type, placement_type, expl_id2, is_operative, brand_id, model_id, serial_number, minsector_id, macrominsector_id, demand_max, demand_min, demand_avg, press_max, press_min, press_avg, head_max, head_min, head_avg, quality_max, quality_min, quality_avg, tstamp, insert_user, lastupdate, lastupdate_user, the_geom, inp_type, closed, broken, buried, irrigation_indicator, pression_entry, pression_exit, depth_valveshaft, regulator_situation, regulator_location, regulator_observ, lin_meters, exit_type, exit_code, drive_type, cat_valve2, ordinarystatus, shutter, brand2, model2, valve_type, to_arc, active, airvalve_param_1, airvalve_param_2)
VALUES('-901', '-901', 32.8100, NULL, 'AIR_VALVE', 'VALVE', 'AIR VALVE DN50', 'FD', '16', '50', NULL, 'UNDEFINED', 1, 2, 2, 1, 5, 'sector2-1d', 2, 'DISTRIBUTION', '3', 'pzone1-1d', NULL, NULL, 3, 'dma2-1d', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'soil1', NULL, NULL, NULL, NULL, 'work1', NULL, NULL, '2024-08-22', NULL, NULL, 'owner1', 2, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, '', '1', NULL, NULL, NULL, NULL, NULL, true, true, NULL, NULL, NULL, NULL, NULL, '204,235,197', '204,235,197', NULL, NULL, NULL, NULL, NULL, NULL, true, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-08-22 17:00:02.000', 'postgres', '2024-08-22 17:00:02.000', 'postgres', 'SRID=25831;POINT (418473.00472849904 4577983.379842222)'::public.geometry, NULL, false, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL);

INSERT INTO arc
(arc_id, code, node_1, node_2, arccat_id, epa_type, sector_id, state, state_type, annotation, observ, "comment", "_sys_length", custom_length, dma_id, presszone_id, soilcat_id, function_type, category_type, fluid_type, location_type, workcat_id, workcat_id_end, buildercat_id, builtdate, enddate, ownercat_id, muni_id, postcode, streetaxis_id, postnumber, postcomplement, streetaxis2_id, postnumber2, postcomplement2, descript, link, verified, the_geom, undelete, label_x, label_y, label_rotation, publish, inventory, expl_id, num_value, feature_type, tstamp, lastupdate, lastupdate_user, insert_user, minsector_id, dqa_id, staticpressure, district_id, "depth", adate, adescript, workcat_id_plan, asset_id, pavcat_id, nodetype_1, elevation1, depth1, staticpress1, nodetype_2, elevation2, depth2, staticpress2, om_state, conserv_state, parent_id, expl_id2, brand_id, model_id, serial_number, macrominsector_id)
VALUES('-901', '-901', '-901', '-902', 'PVC63-PN10', 'PIPE', 5, 1, 2, NULL, NULL, NULL, NULL, NULL, 3, '3', 'soil1', NULL, NULL, NULL, NULL, 'work1', NULL, NULL, '2024-08-22', NULL, 'owner1', 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', '1', 'SRID=25831;LINESTRING (418473.00472849904 4577983.379842222, 418474.19510507485 4577983.667174499)'::public.geometry, NULL, NULL, NULL, NULL, true, true, 2, NULL, 'ARC', '2024-08-22 17:05:32.365', '2024-08-22 17:05:32.436', 'postgres', 'postgres', NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'Asphalt', 'AIR_VALVE', 32.8100, NULL, NULL, 'AIR_VALVE', 32.8100, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
SELECT is((SELECT count(*)::integer FROM arc WHERE arc_id = '-901'), 1, 'INSERT: arc:pipe "-901" was inserted');

UPDATE arc SET custom_length = 1.0000 WHERE arc_id = '-901';
SELECT is((SELECT custom_length FROM arc WHERE arc_id = '-901'), 1.0000, 'UPDATE: arc:pipe "-901" was updated');

DELETE FROM arc WHERE arc_id = '-901';
SELECT is((SELECT count(*)::integer FROM arc WHERE arc_id = '-901'), 0, 'DELETE: arc:pipe "-901" was deleted');

-- arc -> varc
-- initial data is prepared before proceeding with the test
INSERT INTO ve_node_check_valve
(node_id, code, elevation, "depth", node_type, sys_type, nodecat_id, cat_matcat_id, cat_pnom, cat_dnom, cat_dint, epa_type, state, state_type, expl_id, macroexpl_id, sector_id, sector_name, macrosector_id, sector_type, presszone_id, preszone_name, presszone_type, presszone_head, dma_id, dma_name, dma_type, macrodma_id, dqa_id, dqa_name, dqa_type, macrodqa_id, arc_id, parent_id, annotation, observ, "comment", staticpressure, soilcat_id, function_type, category_type, fluid_type, location_type, workcat_id, workcat_id_end, workcat_id_plan, builtdate, enddate, buildercat_id, ownercat_id, muni_id, postcode, district_id, streetname, postnumber, postcomplement, streetname2, postnumber2, postcomplement2, region_id, province_id, descript, svg, rotation, link, verified, undelete, "label", label_x, label_y, label_rotation, publish, inventory, hemisphere, num_value, adate, adescript, accessibility, dma_style, presszone_style, asset_id, om_state, conserv_state, access_type, placement_type, expl_id2, is_operative, brand_id, model_id, serial_number, minsector_id, macrominsector_id, demand_max, demand_min, demand_avg, press_max, press_min, press_avg, head_max, head_min, head_avg, quality_max, quality_min, quality_avg, tstamp, insert_user, lastupdate, lastupdate_user, the_geom, inp_type, closed, broken, buried, irrigation_indicator, pression_entry, pression_exit, depth_valveshaft, regulator_situation, regulator_location, regulator_observ, lin_meters, exit_type, exit_code, drive_type, cat_valve2, ordinarystatus, shutter, brand2, model2, valve_type, to_arc, active, checkvalve_param_1, checkvalve_param_2)
VALUES('-903', '-903', 32.8100, NULL, 'CHECK_VALVE', 'VALVE', 'CHK-VALVE63-PN16', 'FD', '16', '63', 65.00000, 'SHORTPIPE', 1, 2, 2, 1, 5, 'sector2-1d', 2, 'DISTRIBUTION', '3', 'pzone1-1d', NULL, NULL, 3, 'dma2-1d', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'soil1', NULL, NULL, NULL, NULL, 'work1', NULL, NULL, '2024-08-22', NULL, NULL, 'owner1', 2, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, '', '1', NULL, NULL, NULL, NULL, NULL, true, true, NULL, NULL, NULL, NULL, NULL, '204,235,197', '204,235,197', NULL, NULL, NULL, NULL, NULL, NULL, true, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-08-22 17:01:53.000', 'postgres', '2024-08-22 17:01:53.000', 'postgres', 'SRID=25831;POINT (418473.1278709034 4577982.640987795)'::public.geometry, 'SHORTPIPE', false, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL);
INSERT INTO ve_node_check_valve
(node_id, code, elevation, "depth", node_type, sys_type, nodecat_id, cat_matcat_id, cat_pnom, cat_dnom, cat_dint, epa_type, state, state_type, expl_id, macroexpl_id, sector_id, sector_name, macrosector_id, sector_type, presszone_id, preszone_name, presszone_type, presszone_head, dma_id, dma_name, dma_type, macrodma_id, dqa_id, dqa_name, dqa_type, macrodqa_id, arc_id, parent_id, annotation, observ, "comment", staticpressure, soilcat_id, function_type, category_type, fluid_type, location_type, workcat_id, workcat_id_end, workcat_id_plan, builtdate, enddate, buildercat_id, ownercat_id, muni_id, postcode, district_id, streetname, postnumber, postcomplement, streetname2, postnumber2, postcomplement2, region_id, province_id, descript, svg, rotation, link, verified, undelete, "label", label_x, label_y, label_rotation, publish, inventory, hemisphere, num_value, adate, adescript, accessibility, dma_style, presszone_style, asset_id, om_state, conserv_state, access_type, placement_type, expl_id2, is_operative, brand_id, model_id, serial_number, minsector_id, macrominsector_id, demand_max, demand_min, demand_avg, press_max, press_min, press_avg, head_max, head_min, head_avg, quality_max, quality_min, quality_avg, tstamp, insert_user, lastupdate, lastupdate_user, the_geom, inp_type, closed, broken, buried, irrigation_indicator, pression_entry, pression_exit, depth_valveshaft, regulator_situation, regulator_location, regulator_observ, lin_meters, exit_type, exit_code, drive_type, cat_valve2, ordinarystatus, shutter, brand2, model2, valve_type, to_arc, active, checkvalve_param_1, checkvalve_param_2)
VALUES('-904', '-904', 32.8100, NULL, 'CHECK_VALVE', 'VALVE', 'CHK-VALVE63-PN16', 'FD', '16', '63', 65.00000, 'SHORTPIPE', 1, 2, 2, 1, 5, 'sector2-1d', 2, 'DISTRIBUTION', '3', 'pzone1-1d', NULL, NULL, 3, 'dma2-1d', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'soil1', NULL, NULL, NULL, NULL, 'work1', NULL, NULL, '2024-08-22', NULL, NULL, 'owner1', 2, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, 1, 1, NULL, NULL, NULL, '', '1', NULL, NULL, NULL, NULL, NULL, true, true, NULL, NULL, NULL, NULL, NULL, '204,235,197', '204,235,197', NULL, NULL, NULL, NULL, NULL, NULL, true, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-08-22 17:02:03.000', 'postgres', '2024-08-22 17:02:03.000', 'postgres', 'SRID=25831;POINT (418474.44138988364 4577982.928320073)'::public.geometry, 'SHORTPIPE', false, false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, NULL, NULL);

INSERT INTO arc
(arc_id, code, node_1, node_2, arccat_id, epa_type, sector_id, state, state_type, annotation, observ, "comment", "_sys_length", custom_length, dma_id, presszone_id, soilcat_id, function_type, category_type, fluid_type, location_type, workcat_id, workcat_id_end, buildercat_id, builtdate, enddate, ownercat_id, muni_id, postcode, streetaxis_id, postnumber, postcomplement, streetaxis2_id, postnumber2, postcomplement2, descript, link, verified, the_geom, undelete, label_x, label_y, label_rotation, publish, inventory, expl_id, num_value, feature_type, tstamp, lastupdate, lastupdate_user, insert_user, minsector_id, dqa_id, staticpressure, district_id, "depth", adate, adescript, workcat_id_plan, asset_id, pavcat_id, nodetype_1, elevation1, depth1, staticpress1, nodetype_2, elevation2, depth2, staticpress2, om_state, conserv_state, parent_id, expl_id2, brand_id, model_id, serial_number, macrominsector_id)
VALUES('-902', '-902', '-903', '-904', 'VIRTUAL', 'PIPE', 5, 1, 2, NULL, NULL, NULL, NULL, NULL, 3, '3', 'soil1', NULL, NULL, NULL, NULL, 'work1', NULL, NULL, '2024-08-22', NULL, 'owner1', 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '', '1', 'SRID=25831;LINESTRING (418473.1278709034 4577982.640987795, 418474.44138988364 4577982.928320073)'::public.geometry, NULL, NULL, NULL, NULL, true, true, 2, NULL, 'ARC', '2024-08-22 17:05:48.525', '2024-08-22 17:05:48.577', 'postgres', 'postgres', NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, 'Asphalt', 'CHECK_VALVE', 32.8100, NULL, NULL, 'CHECK_VALVE', 32.8100, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
SELECT is((SELECT count(*)::integer FROM arc WHERE arc_id = '-902'), 1, 'INSERT: arc:varc "-902" was inserted');

UPDATE arc SET custom_length = 1.0000 WHERE arc_id = '-902';
SELECT is((SELECT custom_length FROM arc WHERE arc_id = '-902'), 1.0000, 'UPDATE: arc:varc "-902" was updated');

DELETE FROM arc WHERE arc_id = '-902';
SELECT is((SELECT count(*)::integer FROM arc WHERE arc_id = '-902'), 0, 'DELETE: arc:varc "-902" was deleted');


SELECT * FROM finish();

ROLLBACK;
Loading

0 comments on commit 9bc1db6

Please sign in to comment.