@@ -33,7 +33,7 @@ def setUpClass(cls):
3333
3434 def test_build_boundaries (self ):
3535 print ('\n INFO: Validating build boundaries...' )
36- db_gpkg = get_copy_gpkg_conn ('test_toolbar_gpkg ' )
36+ db_gpkg = get_copy_gpkg_conn ('test_build_boundaries_gpkg ' )
3737 res , code , msg = db_gpkg .test_connection ()
3838 self .assertTrue (res , msg )
3939
@@ -99,7 +99,7 @@ def test_build_boundaries(self):
9999
100100 def test_build_boundaries_with_empty_geom (self ):
101101 print ('\n INFO: Validating build boundaries, null geometries of the input layer are removed...' )
102- db_gpkg = get_copy_gpkg_conn ('test_toolbar_empty_geom_gpkg ' )
102+ db_gpkg = get_copy_gpkg_conn ('test_build_boundaries_empty_geom_gpkg ' )
103103 res , code , msg = db_gpkg .test_connection ()
104104 self .assertTrue (res , msg )
105105
@@ -120,6 +120,43 @@ def test_build_boundaries_with_empty_geom(self):
120120 self .assertEqual (boundary_layer .selectedFeatureCount (), 0 ,
121121 'Null features count does not match for the layer boundary layer' )
122122
123+ def test_build_boundaries_with_invalid_geom (self ):
124+ print ('\n INFO: Validating build boundaries, invalid geometry of the input layer are removed...' )
125+ db_gpkg = get_copy_gpkg_conn ('test_build_boundaries_invalid_geom_gpkg' )
126+ res , code , msg = db_gpkg .test_connection ()
127+ self .assertTrue (res , msg )
128+
129+ boundary_layer = self .app .core .get_layer (db_gpkg , db_gpkg .names .LC_BOUNDARY_T , load = True )
130+ self .assertEqual (boundary_layer .featureCount (), 16 , 'Features count does not match for the layer boundary layer' )
131+
132+ self .toolbar .build_boundaries (db_gpkg , True )
133+
134+ self .assertEqual (boundary_layer .featureCount (), 1 , 'Features count does not match for the layer boundary layer' )
135+
136+ exp = "is_empty_or_null($geometry)"
137+ boundary_layer .selectByExpression (exp )
138+ self .assertEqual (boundary_layer .selectedFeatureCount (), 0 ,
139+ 'Null features count does not match for the layer boundary layer' )
140+
141+
142+ def test_build_boundaries_with_invalid_geom_in_processing (self ):
143+ print ('\n INFO: Validating build boundaries, invalid geometries generated when running the processing algorithm are fixed...' )
144+ db_gpkg = get_copy_gpkg_conn ('test_build_boundaries_fix_geoms_gpkg' )
145+ res , code , msg = db_gpkg .test_connection ()
146+ self .assertTrue (res , msg )
147+
148+ boundary_layer = self .app .core .get_layer (db_gpkg , db_gpkg .names .LC_BOUNDARY_T , load = True )
149+ self .assertEqual (boundary_layer .featureCount (), 7 , 'Features count does not match for the layer boundary layer' )
150+
151+ self .toolbar .build_boundaries (db_gpkg , True )
152+
153+ self .assertEqual (boundary_layer .featureCount (), 17 , 'Features count does not match for the layer boundary layer' )
154+
155+ exp = "is_empty_or_null($geometry)"
156+ boundary_layer .selectByExpression (exp )
157+ self .assertEqual (boundary_layer .selectedFeatureCount (), 0 ,
158+ 'Null features count does not match for the layer boundary layer' )
159+
123160 def test_check_build_boundaries (self ):
124161 print ('\n INFO: Validation of the definition of boundaries...' )
125162
0 commit comments