From f811d7ccccd6919dbba716f275038e1323cff08c Mon Sep 17 00:00:00 2001 From: Anna Petrasova Date: Thu, 19 Sep 2024 16:29:33 -0400 Subject: [PATCH 1/2] tests: fix tests and use layers from nc_spm_basic dataset --- .../v.centroids/testsuite/test_v_centroids.py | 34 ++++++++++++------- .../v.to.lines/testsuite/test_v_to_lines.py | 8 ++--- .../v.what.vect/testsuite/test_v_what_vect.py | 17 +++++----- vector/v.profile/testsuite/test_v_profile.py | 2 +- vector/v.random/testsuite/test_v_random.py | 2 +- vector/v.select/testsuite/test_v_select.py | 33 +++++------------- vector/v.surf.rst/testsuite/test_vsurfrst.py | 4 +-- 7 files changed, 47 insertions(+), 53 deletions(-) diff --git a/scripts/v.centroids/testsuite/test_v_centroids.py b/scripts/v.centroids/testsuite/test_v_centroids.py index 4b0654748a5..a7f56464ef6 100644 --- a/scripts/v.centroids/testsuite/test_v_centroids.py +++ b/scripts/v.centroids/testsuite/test_v_centroids.py @@ -12,37 +12,47 @@ class TestVCentroids(TestCase): """Test v.centroids script""" - mapName = "busroute11" - outRouteMap = "busroute11_boundary" - fromType = "line" - toType = "boundary" - outAreaMap = "busroute11_area" + region_line = "region_line" + region_boundary = "region_boundary" + region_area = "region_area" + output = "output" @classmethod def setUpClass(cls): """Create an area from a closed line""" + cls.runModule("v.in.region", output=cls.region_line, type="line") + cls.runModule("v.in.region", output=cls.region_area, type="area") cls.runModule( "v.type", - input=cls.mapName, - output=cls.outRouteMap, - from_type=cls.fromType, - to_type=cls.toType, + input=cls.region_line, + output=cls.region_boundary, + from_type="line", + to_type="boundary", ) @classmethod def tearDownClass(cls): """Remove the generated maps""" cls.runModule( - "g.remove", flags="f", type="vector", name=(cls.outRouteMap, cls.outAreaMap) + "g.remove", + flags="f", + type="vector", + name=(cls.region_line, cls.region_area, cls.region_boundary), ) + def tearDown(self): + """Remove the generated maps""" + self.runModule("g.remove", flags="f", type="vector", name=self.output) + def test_area(self): """Adds missing centroids to closed boundaries test""" module = SimpleModule( - "v.centroids", input=self.outRouteMap, output=self.outAreaMap + "v.centroids", input=self.region_boundary, output=self.output ) self.assertModule(module) - self.assertVectorExists(self.outAreaMap) + self.assertVectorInfoEqualsVectorInfo( + self.output, self.region_area, precision=1e-6 + ) if __name__ == "__main__": diff --git a/scripts/v.to.lines/testsuite/test_v_to_lines.py b/scripts/v.to.lines/testsuite/test_v_to_lines.py index c7184a28b6a..7d832c232f5 100644 --- a/scripts/v.to.lines/testsuite/test_v_to_lines.py +++ b/scripts/v.to.lines/testsuite/test_v_to_lines.py @@ -12,11 +12,11 @@ class TestVDToLines(TestCase): """Test v.to.lines script""" - inputMap = "boundary_municp" - outputMap = "boundary_municp_lines" + inputMap = "boundary_state" + outputMap = "boundary_state_lines" - inputMap2 = "geodetic_pts" - outputMap2 = "geodetic_pts_lines" + inputMap2 = "schools" + outputMap2 = "schools_lines" @classmethod def tearDownClass(cls): diff --git a/scripts/v.what.vect/testsuite/test_v_what_vect.py b/scripts/v.what.vect/testsuite/test_v_what_vect.py index 09ade33668f..2385a71c400 100644 --- a/scripts/v.what.vect/testsuite/test_v_what_vect.py +++ b/scripts/v.what.vect/testsuite/test_v_what_vect.py @@ -9,7 +9,6 @@ from grass.gunittest.gmodules import SimpleModule from grass.script.core import run_command -from grass.script.utils import decode class TestVWhatVect(TestCase): @@ -29,20 +28,20 @@ def tearDownClass(cls): def test_what_vect(self): """Uploads vector values""" - run_command("v.db.addcolumn", map=self.mapName, columns="urb_name varchar(25)") + run_command("v.db.addcolumn", map=self.mapName, columns="geology_cat integer") module = SimpleModule( "v.what.vect", map=self.mapName, - query_map="urbanarea", - column="urb_name", - query_column="NAME", + query_map="geology", + column="geology_cat", + query_column="cat", ) self.assertModule(module) - - m = SimpleModule("v.db.select", map=self.mapName) - self.assertModule(m) - self.assertRegex(decode(m.outputs.stdout), "urb_name") + minmax = "min=11\nmax=1810" + self.assertVectorFitsUnivar( + map=self.mapName, column="geology_cat", reference=minmax + ) if __name__ == "__main__": diff --git a/vector/v.profile/testsuite/test_v_profile.py b/vector/v.profile/testsuite/test_v_profile.py index 63a877d6e08..cf553936cfc 100644 --- a/vector/v.profile/testsuite/test_v_profile.py +++ b/vector/v.profile/testsuite/test_v_profile.py @@ -72,7 +72,7 @@ class TestProfiling(TestCase): to_remove = [] points = "test_v_profile_points" multiline = "test_v_profile_multiline" - in_points = "poi_names_wake" + in_points = "points_of_interest" in_map = "roadsmajor" where = "cat='354'" prof_ponts = (647952, 236176, 647950, 236217) diff --git a/vector/v.random/testsuite/test_v_random.py b/vector/v.random/testsuite/test_v_random.py index e5cc95a93db..aaf26fad1db 100644 --- a/vector/v.random/testsuite/test_v_random.py +++ b/vector/v.random/testsuite/test_v_random.py @@ -17,7 +17,7 @@ class TestVRandom(TestCase): output = "test01" output2 = "test02" npoints = 100 - state = "nc_state" + state = "boundary_state" zmin = 10 zmax = 120 diff --git a/vector/v.select/testsuite/test_v_select.py b/vector/v.select/testsuite/test_v_select.py index c74cdb53761..b8564505a6a 100644 --- a/vector/v.select/testsuite/test_v_select.py +++ b/vector/v.select/testsuite/test_v_select.py @@ -13,22 +13,9 @@ class TestRasterReport(TestCase): - binput = "bridges" + binput = "zipcodes" ainput = "geology" output = "testvselect" - overlap = "geonames_wake" - disjoint = "schools_wake" - equals = "streets_wake" - touches = "zipcodes_wake" - within = "geonames_wake" - - @classmethod - def setUpClass(cls): - cls.use_temp_region() - - @classmethod - def tearDownClass(cls): - cls.del_temp_region() def tearDown(cls): cls.runModule("g.remove", type="vector", flags="f", name=cls.output) @@ -42,8 +29,8 @@ def test_opo(self): output=self.output, operator="overlap", ) - topology = {"points": 1088, "lines": 0, "areas": 0} - self.assertVectorFitsTopoInfo(self.overlap, topology) + topology = {"areas": 97} + self.assertVectorFitsTopoInfo(self.output, topology) def test_opd(self): """Testign operator disjoint""" @@ -54,8 +41,8 @@ def test_opd(self): output=self.output, operator="disjoint", ) - topology = {"points": 167, "lines": 0, "areas": 0} - self.assertVectorFitsTopoInfo(self.disjoint, topology) + topology = {"areas": 1770} + self.assertVectorFitsTopoInfo(self.output, topology) def test_ope(self): """Testing operator equals""" @@ -66,8 +53,7 @@ def test_ope(self): output=self.output, operator="equals", ) - topology = {"points": 0, "lines": 49746, "areas": 0} - self.assertVectorFitsTopoInfo(self.equals, topology) + self.assertVectorDoesNotExist(self.output) def test_opt(self): """Testing operator touches""" @@ -78,8 +64,7 @@ def test_opt(self): output=self.output, operator="touches", ) - topology = {"points": 0, "lines": 0, "areas": 48} - self.assertVectorFitsTopoInfo(self.touches, topology) + self.assertVectorDoesNotExist(self.output) def test_opw(self): """Testing operator within""" @@ -90,8 +75,8 @@ def test_opw(self): output=self.output, operator="within", ) - topology = {"points": 1088, "lines": 0, "areas": 0} - self.assertVectorFitsTopoInfo(self.within, topology) + topology = {"areas": 17} + self.assertVectorFitsTopoInfo(self.output, topology) if __name__ == "__main__": diff --git a/vector/v.surf.rst/testsuite/test_vsurfrst.py b/vector/v.surf.rst/testsuite/test_vsurfrst.py index 7d46eacb2f0..7cfe08506f1 100644 --- a/vector/v.surf.rst/testsuite/test_vsurfrst.py +++ b/vector/v.surf.rst/testsuite/test_vsurfrst.py @@ -22,10 +22,10 @@ class TestVsurfrst(TestCase): @classmethod def setUpClass(cls): cls.use_temp_region() - cls.runModule("g.region", vector="elev_lid792_randpts", res=1) + cls.runModule("g.region", vector="elev_points", res=1) cls.runModule( "v.to.3d", - input="elev_lid792_randpts", + input="elev_points", type="point", output="elev_points3d", column="value", From 4c006f4ccbb2cd3dafa1551e310aeb979c9a4c9a Mon Sep 17 00:00:00 2001 From: Anna Petrasova Date: Thu, 19 Sep 2024 22:31:49 -0400 Subject: [PATCH 2/2] remove tests for now --- scripts/v.to.lines/testsuite/test_v_to_lines.py | 8 ++++---- vector/v.profile/testsuite/test_v_profile.py | 2 +- vector/v.random/testsuite/test_v_random.py | 2 +- vector/v.surf.rst/testsuite/test_vsurfrst.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/v.to.lines/testsuite/test_v_to_lines.py b/scripts/v.to.lines/testsuite/test_v_to_lines.py index 7d832c232f5..c7184a28b6a 100644 --- a/scripts/v.to.lines/testsuite/test_v_to_lines.py +++ b/scripts/v.to.lines/testsuite/test_v_to_lines.py @@ -12,11 +12,11 @@ class TestVDToLines(TestCase): """Test v.to.lines script""" - inputMap = "boundary_state" - outputMap = "boundary_state_lines" + inputMap = "boundary_municp" + outputMap = "boundary_municp_lines" - inputMap2 = "schools" - outputMap2 = "schools_lines" + inputMap2 = "geodetic_pts" + outputMap2 = "geodetic_pts_lines" @classmethod def tearDownClass(cls): diff --git a/vector/v.profile/testsuite/test_v_profile.py b/vector/v.profile/testsuite/test_v_profile.py index cf553936cfc..63a877d6e08 100644 --- a/vector/v.profile/testsuite/test_v_profile.py +++ b/vector/v.profile/testsuite/test_v_profile.py @@ -72,7 +72,7 @@ class TestProfiling(TestCase): to_remove = [] points = "test_v_profile_points" multiline = "test_v_profile_multiline" - in_points = "points_of_interest" + in_points = "poi_names_wake" in_map = "roadsmajor" where = "cat='354'" prof_ponts = (647952, 236176, 647950, 236217) diff --git a/vector/v.random/testsuite/test_v_random.py b/vector/v.random/testsuite/test_v_random.py index aaf26fad1db..e5cc95a93db 100644 --- a/vector/v.random/testsuite/test_v_random.py +++ b/vector/v.random/testsuite/test_v_random.py @@ -17,7 +17,7 @@ class TestVRandom(TestCase): output = "test01" output2 = "test02" npoints = 100 - state = "boundary_state" + state = "nc_state" zmin = 10 zmax = 120 diff --git a/vector/v.surf.rst/testsuite/test_vsurfrst.py b/vector/v.surf.rst/testsuite/test_vsurfrst.py index 7cfe08506f1..7d46eacb2f0 100644 --- a/vector/v.surf.rst/testsuite/test_vsurfrst.py +++ b/vector/v.surf.rst/testsuite/test_vsurfrst.py @@ -22,10 +22,10 @@ class TestVsurfrst(TestCase): @classmethod def setUpClass(cls): cls.use_temp_region() - cls.runModule("g.region", vector="elev_points", res=1) + cls.runModule("g.region", vector="elev_lid792_randpts", res=1) cls.runModule( "v.to.3d", - input="elev_points", + input="elev_lid792_randpts", type="point", output="elev_points3d", column="value",