[GRASS-SVN] r74226 - in grass/trunk: lib/python/gunittest/testsuite lib/python/pygrass/gis/testsuite lib/python/pygrass/messages/testsuite lib/python/pygrass/modules/grid/testsuite lib/python/pygrass/modules/interface/testsuite lib/python/pygrass/modules/testsuite lib/python/pygrass/raster/testsuite lib/python/pygrass/rpc/testsuite lib/python/pygrass/shell/testsuite lib/python/pygrass/testsuite lib/python/pygrass/vector/testsuite lib/python/script/testsuite lib/python/temporal/testsuite temporal/t.rast.extract/testsuite temporal/t.rast.univar/testsuite temporal/t.rast3d.extract/testsuite temporal/t.rast3d.univar/testsuite vector/v.extract/testsuite vector/v.in.lidar/testsuite vector/v.in.pdal/testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Mar 12 15:22:35 PDT 2019
Author: neteler
Date: 2019-03-12 15:22:35 -0700 (Tue, 12 Mar 2019)
New Revision: 74226
Added:
grass/trunk/lib/python/gunittest/testsuite/test_gunitest_doctests.py
grass/trunk/lib/python/pygrass/gis/testsuite/test_pygrass_gis_doctests.py
grass/trunk/lib/python/pygrass/messages/testsuite/test_pygrass_messages_doctests.py
grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_pygrass_modules_grid_doctests.py
grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_pygrass_modules_interface_doctests.py
grass/trunk/lib/python/pygrass/modules/testsuite/test_pygrass_modules_doctests.py
grass/trunk/lib/python/pygrass/raster/testsuite/test_pygrass_raster.py
grass/trunk/lib/python/pygrass/raster/testsuite/test_pygrass_raster_doctests.py
grass/trunk/lib/python/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py
grass/trunk/lib/python/pygrass/shell/testsuite/test_pygrass_shell_doctests.py
grass/trunk/lib/python/pygrass/testsuite/test_pygrass_doctests.py
grass/trunk/lib/python/pygrass/vector/testsuite/test_pygrass_vector_doctests.py
grass/trunk/lib/python/script/testsuite/test_script_doctests.py
grass/trunk/lib/python/script/testsuite/test_script_raster.py
grass/trunk/lib/python/temporal/testsuite/test_temporal_doctests.py
grass/trunk/temporal/t.rast.extract/testsuite/test_t_rast_extract.py
grass/trunk/temporal/t.rast.univar/testsuite/test_t_rast_univar.py
grass/trunk/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py
grass/trunk/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py
grass/trunk/vector/v.extract/testsuite/test_v_extract.py
grass/trunk/vector/v.in.lidar/testsuite/test_v_in_lidar_basic.py
grass/trunk/vector/v.in.lidar/testsuite/test_v_in_lidar_filter.py
grass/trunk/vector/v.in.lidar/testsuite/test_v_in_pdal_basic.py
grass/trunk/vector/v.in.lidar/testsuite/test_v_in_pdal_filter.py
Removed:
grass/trunk/lib/python/gunittest/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/gis/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/messages/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/raster/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/raster/testsuite/test_raster.py
grass/trunk/lib/python/pygrass/rpc/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/shell/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/testsuite/test_doctests.py
grass/trunk/lib/python/pygrass/vector/testsuite/test_doctests.py
grass/trunk/lib/python/script/testsuite/test_doctests.py
grass/trunk/lib/python/script/testsuite/test_raster.py
grass/trunk/lib/python/temporal/testsuite/test_doctests.py
grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py
grass/trunk/temporal/t.rast.univar/testsuite/test_univar.py
grass/trunk/temporal/t.rast3d.extract/testsuite/test_extract.py
grass/trunk/temporal/t.rast3d.univar/testsuite/test_univar.py
grass/trunk/vector/v.extract/testsuite/test_extract.py
grass/trunk/vector/v.in.lidar/testsuite/basic_test.py
grass/trunk/vector/v.in.lidar/testsuite/filter_test.py
grass/trunk/vector/v.in.pdal/testsuite/basic_test.py
grass/trunk/vector/v.in.pdal/testsuite/filter_test.py
Log:
testsuite: use unique names on test modules to better support pytest (fixes #3792) (contributed by pmav99)
Deleted: grass/trunk/lib/python/gunittest/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/gunittest/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/gunittest/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,41 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.gunittest.gmodules
-import grass.gunittest.checkers
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(grass.gunittest.gmodules))
- tests.addTests(doctest.DocTestSuite(grass.gunittest.checkers))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/gunittest/testsuite/test_gunitest_doctests.py (from rev 74225, grass/trunk/lib/python/gunittest/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/gunittest/testsuite/test_gunitest_doctests.py (rev 0)
+++ grass/trunk/lib/python/gunittest/testsuite/test_gunitest_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.gunittest.gmodules
+import grass.gunittest.checkers
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(grass.gunittest.gmodules))
+ tests.addTests(doctest.DocTestSuite(grass.gunittest.checkers))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/gis/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/gis/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/gis/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-from grass.pygrass import gis
-from grass.pygrass.gis import region
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
-
- from grass.pygrass import utils
- from grass.script.core import run_command
- utils.create_test_vector_map(gis.test_vector_name)
- utils.create_test_vector_map(gis.region.test_vector_name)
- run_command("g.region", n=50, s=0, e=60, w=0, res=1)
- run_command("r.mapcalc", expression="%s = 1"%(gis.test_raster_name),
- overwrite=True)
- run_command("r.mapcalc", expression="%s = 1"%(gis.region.test_raster_name),
- overwrite=True)
- run_command("g.region", n=40, s=0, e=40, w=0, res=2)
-
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(gis))
- tests.addTests(doctest.DocTestSuite(region))
- return tests
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/gis/testsuite/test_pygrass_gis_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/gis/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/gis/testsuite/test_pygrass_gis_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/gis/testsuite/test_pygrass_gis_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+from grass.pygrass import gis
+from grass.pygrass.gis import region
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+
+ from grass.pygrass import utils
+ from grass.script.core import run_command
+ utils.create_test_vector_map(gis.test_vector_name)
+ utils.create_test_vector_map(gis.region.test_vector_name)
+ run_command("g.region", n=50, s=0, e=60, w=0, res=1)
+ run_command("r.mapcalc", expression="%s = 1"%(gis.test_raster_name),
+ overwrite=True)
+ run_command("r.mapcalc", expression="%s = 1"%(gis.region.test_raster_name),
+ overwrite=True)
+ run_command("g.region", n=40, s=0, e=40, w=0, res=2)
+
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(gis))
+ tests.addTests(doctest.DocTestSuite(region))
+ return tests
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/messages/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/messages/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/messages/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.pygrass.messages as gmessages
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(gmessages))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/messages/testsuite/test_pygrass_messages_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/messages/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/messages/testsuite/test_pygrass_messages_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/messages/testsuite/test_pygrass_messages_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.pygrass.messages as gmessages
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(gmessages))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.pygrass.modules as gmodules
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
-
- tests.addTests(doctest.DocTestSuite(gmodules.shortcuts))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_pygrass_modules_grid_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_pygrass_modules_grid_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/modules/grid/testsuite/test_pygrass_modules_grid_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.pygrass.modules as gmodules
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+
+ tests.addTests(doctest.DocTestSuite(gmodules.shortcuts))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,42 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.pygrass.modules as gmodules
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(gmodules.interface.flag))
- tests.addTests(doctest.DocTestSuite(gmodules.interface.module))
- tests.addTests(doctest.DocTestSuite(gmodules.interface.parameter))
-
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_pygrass_modules_interface_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_pygrass_modules_interface_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/modules/interface/testsuite/test_pygrass_modules_interface_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.pygrass.modules as gmodules
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(gmodules.interface.flag))
+ tests.addTests(doctest.DocTestSuite(gmodules.interface.module))
+ tests.addTests(doctest.DocTestSuite(gmodules.interface.parameter))
+
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,43 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-from grass.pygrass.modules import shortcuts, grid, interface
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(interface))
- tests.addTests(doctest.DocTestSuite(grid.grid))
- tests.addTests(doctest.DocTestSuite(grid.patch))
- tests.addTests(doctest.DocTestSuite(grid.split))
- tests.addTests(doctest.DocTestSuite(shortcuts))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/modules/testsuite/test_pygrass_modules_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/modules/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/modules/testsuite/test_pygrass_modules_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/modules/testsuite/test_pygrass_modules_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+from grass.pygrass.modules import shortcuts, grid, interface
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(interface))
+ tests.addTests(doctest.DocTestSuite(grid.grid))
+ tests.addTests(doctest.DocTestSuite(grid.patch))
+ tests.addTests(doctest.DocTestSuite(grid.split))
+ tests.addTests(doctest.DocTestSuite(shortcuts))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/raster/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/raster/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,73 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.pygrass.raster as pgrass
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
-
- from grass.pygrass.modules import Module
- Module("g.region", n=40, s=0, e=40, w=0, res=10)
- Module("r.mapcalc",
- expression="%s = row() + (10 * col())" % (pgrass.test_raster_name),
- overwrite=True)
- Module("r.support", map=pgrass.test_raster_name,
- title="A test map",
- history="Generated by r.mapcalc",
- description="This is a test map")
- cats = """11:A
- 12:B
- 13:C
- 14:D
- 21:E
- 22:F
- 23:G
- 24:H
- 31:I
- 32:J
- 33:K
- 34:L
- 41:M
- 42:n
- 43:O
- 44:P"""
- Module("r.category", rules="-", map=pgrass.test_raster_name,
- stdin_=cats, separator=":")
-
- Module("r.mapcalc",
- expression="%s = row() + (10 * col())" % (pgrass.abstract.test_raster_name),
- overwrite=True)
-
- tests.addTests(doctest.DocTestSuite(pgrass))
- tests.addTests(doctest.DocTestSuite(pgrass.abstract))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/raster/testsuite/test_pygrass_raster.py (from rev 74225, grass/trunk/lib/python/pygrass/raster/testsuite/test_raster.py)
===================================================================
--- grass/trunk/lib/python/pygrass/raster/testsuite/test_pygrass_raster.py (rev 0)
+++ grass/trunk/lib/python/pygrass/raster/testsuite/test_pygrass_raster.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,93 @@
+# -*- coding: utf-8 -*-
+from grass.exceptions import OpenError
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+from grass.pygrass.raster import RasterRow
+
+
+class RasterRowTestCase(TestCase):
+
+ name = "RasterRowTestCase_map"
+
+ @classmethod
+ def setUpClass(cls):
+ """Create test raster map and region"""
+ cls.use_temp_region()
+ cls.runModule("g.region", n=40, s=0, e=40, w=0, res=10)
+ cls.runModule("r.mapcalc", expression="%s = row() + (10.0 * col())" % (cls.name),
+ overwrite=True)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the generated vector map, if exist"""
+ cls.runModule("g.remove", flags='f', type='raster',
+ name=cls.name)
+ cls.del_temp_region()
+
+ def test_type(self):
+ r = RasterRow(self.name)
+ r.open(mode='r')
+ self.assertTrue(r.mtype, 'DCELL')
+ r.close()
+
+ def test_isopen(self):
+ r = RasterRow(self.name)
+ self.assertFalse(r.is_open())
+ r.open(mode='r')
+ self.assertTrue(r.is_open())
+ r.close()
+ self.assertFalse(r.is_open())
+
+ def test_name(self):
+ r = RasterRow(self.name)
+ r.open(mode='r')
+ self.assertEqual(r.name, self.name)
+ fullname = "{name}@{mapset}".format(name=r.name, mapset=r.mapset)
+ self.assertEqual(r.fullname(), fullname)
+ r.close()
+
+ def test_exist(self):
+ notexist = RasterRow(self.name + 'notexist')
+ self.assertFalse(notexist.exist())
+ exist = RasterRow(self.name)
+ self.assertTrue(exist.exist())
+
+ def test_open_r(self):
+ notexist = RasterRow(self.name + 'notexist')
+ with self.assertRaises(OpenError):
+ # raster does not exist
+ notexist.open(mode='r')
+ r = RasterRow(self.name)
+ r.open(mode='r', mtype='FCELL')
+ # ignore the mtype if is open in read mode
+ self.assertEqual(r.mtype, 'DCELL')
+ r.close()
+
+ def test_open_w(self):
+ r = RasterRow(self.name)
+ with self.assertRaises(OpenError):
+ # raster type is not defined!
+ r.open(mode='w')
+ with self.assertRaises(OpenError):
+ # raster already exist
+ r.open(mode='w', mtype='DCELL')
+ # open in write mode and overwrite
+ r.open(mode='w', mtype='DCELL', overwrite=True)
+ self.assertTrue(r.mtype, 'DCELL')
+ r.close()
+
+ def test_row_range(self):
+ r = RasterRow(self.name)
+ with self.assertRaises(IndexError):
+ # Map is not open yet
+ r[1]
+ with self.assertRaises(IndexError):
+ # Index is out of range
+ r.open()
+ r[9999]
+ r.close()
+
+
+if __name__ == '__main__':
+ test()
Copied: grass/trunk/lib/python/pygrass/raster/testsuite/test_pygrass_raster_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/raster/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/raster/testsuite/test_pygrass_raster_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/raster/testsuite/test_pygrass_raster_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.pygrass.raster as pgrass
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+
+ from grass.pygrass.modules import Module
+ Module("g.region", n=40, s=0, e=40, w=0, res=10)
+ Module("r.mapcalc",
+ expression="%s = row() + (10 * col())" % (pgrass.test_raster_name),
+ overwrite=True)
+ Module("r.support", map=pgrass.test_raster_name,
+ title="A test map",
+ history="Generated by r.mapcalc",
+ description="This is a test map")
+ cats = """11:A
+ 12:B
+ 13:C
+ 14:D
+ 21:E
+ 22:F
+ 23:G
+ 24:H
+ 31:I
+ 32:J
+ 33:K
+ 34:L
+ 41:M
+ 42:n
+ 43:O
+ 44:P"""
+ Module("r.category", rules="-", map=pgrass.test_raster_name,
+ stdin_=cats, separator=":")
+
+ Module("r.mapcalc",
+ expression="%s = row() + (10 * col())" % (pgrass.abstract.test_raster_name),
+ overwrite=True)
+
+ tests.addTests(doctest.DocTestSuite(pgrass))
+ tests.addTests(doctest.DocTestSuite(pgrass.abstract))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/raster/testsuite/test_raster.py
===================================================================
--- grass/trunk/lib/python/pygrass/raster/testsuite/test_raster.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/raster/testsuite/test_raster.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,93 +0,0 @@
-# -*- coding: utf-8 -*-
-from grass.exceptions import OpenError
-from grass.gunittest.case import TestCase
-from grass.gunittest.main import test
-
-from grass.pygrass.raster import RasterRow
-
-
-class RasterRowTestCase(TestCase):
-
- name = "RasterRowTestCase_map"
-
- @classmethod
- def setUpClass(cls):
- """Create test raster map and region"""
- cls.use_temp_region()
- cls.runModule("g.region", n=40, s=0, e=40, w=0, res=10)
- cls.runModule("r.mapcalc", expression="%s = row() + (10.0 * col())" % (cls.name),
- overwrite=True)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the generated vector map, if exist"""
- cls.runModule("g.remove", flags='f', type='raster',
- name=cls.name)
- cls.del_temp_region()
-
- def test_type(self):
- r = RasterRow(self.name)
- r.open(mode='r')
- self.assertTrue(r.mtype, 'DCELL')
- r.close()
-
- def test_isopen(self):
- r = RasterRow(self.name)
- self.assertFalse(r.is_open())
- r.open(mode='r')
- self.assertTrue(r.is_open())
- r.close()
- self.assertFalse(r.is_open())
-
- def test_name(self):
- r = RasterRow(self.name)
- r.open(mode='r')
- self.assertEqual(r.name, self.name)
- fullname = "{name}@{mapset}".format(name=r.name, mapset=r.mapset)
- self.assertEqual(r.fullname(), fullname)
- r.close()
-
- def test_exist(self):
- notexist = RasterRow(self.name + 'notexist')
- self.assertFalse(notexist.exist())
- exist = RasterRow(self.name)
- self.assertTrue(exist.exist())
-
- def test_open_r(self):
- notexist = RasterRow(self.name + 'notexist')
- with self.assertRaises(OpenError):
- # raster does not exist
- notexist.open(mode='r')
- r = RasterRow(self.name)
- r.open(mode='r', mtype='FCELL')
- # ignore the mtype if is open in read mode
- self.assertEqual(r.mtype, 'DCELL')
- r.close()
-
- def test_open_w(self):
- r = RasterRow(self.name)
- with self.assertRaises(OpenError):
- # raster type is not defined!
- r.open(mode='w')
- with self.assertRaises(OpenError):
- # raster already exist
- r.open(mode='w', mtype='DCELL')
- # open in write mode and overwrite
- r.open(mode='w', mtype='DCELL', overwrite=True)
- self.assertTrue(r.mtype, 'DCELL')
- r.close()
-
- def test_row_range(self):
- r = RasterRow(self.name)
- with self.assertRaises(IndexError):
- # Map is not open yet
- r[1]
- with self.assertRaises(IndexError):
- # Index is out of range
- r.open()
- r[9999]
- r.close()
-
-
-if __name__ == '__main__':
- test()
Deleted: grass/trunk/lib/python/pygrass/rpc/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/rpc/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/rpc/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,49 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.pygrass.rpc as pygrpc
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
-
- from grass.pygrass import utils
- from grass.pygrass.modules import Module
- Module("g.region", n=40, s=0, e=40, w=0, res=10)
- Module("r.mapcalc", expression="%s = row() + (10 * col())"%(pygrpc.test_raster_name),
- overwrite=True)
- utils.create_test_vector_map(pygrpc.test_vector_name)
-
-
- tests.addTests(doctest.DocTestSuite(pygrpc))
- tests.addTests(doctest.DocTestSuite(pygrpc.base))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/rpc/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.pygrass.rpc as pygrpc
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+
+ from grass.pygrass import utils
+ from grass.pygrass.modules import Module
+ Module("g.region", n=40, s=0, e=40, w=0, res=10)
+ Module("r.mapcalc", expression="%s = row() + (10 * col())"%(pygrpc.test_raster_name),
+ overwrite=True)
+ utils.create_test_vector_map(pygrpc.test_vector_name)
+
+
+ tests.addTests(doctest.DocTestSuite(pygrpc))
+ tests.addTests(doctest.DocTestSuite(pygrpc.base))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/shell/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/shell/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/shell/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,40 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-from grass.pygrass.shell import conversion, show
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(conversion))
- tests.addTests(doctest.DocTestSuite(show))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/shell/testsuite/test_pygrass_shell_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/shell/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/shell/testsuite/test_pygrass_shell_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/shell/testsuite/test_pygrass_shell_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+from grass.pygrass.shell import conversion, show
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(conversion))
+ tests.addTests(doctest.DocTestSuite(show))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,47 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.pygrass.utils as gutils
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- from grass.script.core import run_command
-
- gutils.create_test_vector_map(gutils.test_vector_name)
-
- run_command("g.region", n=50, s=0, e=60, w=0, res=1)
- run_command("r.mapcalc", expression="%s = 1"%(gutils.test_raster_name),
- overwrite=True)
-
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(gutils))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/testsuite/test_pygrass_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/testsuite/test_pygrass_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/testsuite/test_pygrass_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.pygrass.utils as gutils
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ from grass.script.core import run_command
+
+ gutils.create_test_vector_map(gutils.test_vector_name)
+
+ run_command("g.region", n=50, s=0, e=60, w=0, res=1)
+ run_command("r.mapcalc", expression="%s = 1"%(gutils.test_raster_name),
+ overwrite=True)
+
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(gutils))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/pygrass/vector/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/pygrass/vector/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,54 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.pygrass.vector as gvector
-import grass.pygrass.utils as gutils
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
-
- from grass.pygrass import utils
- utils.create_test_vector_map(gvector.test_vector_name)
- utils.create_test_vector_map(gvector.abstract.test_vector_name)
- utils.create_test_vector_map(gvector.geometry.test_vector_name)
- utils.create_test_vector_map(gvector.find.test_vector_name)
- utils.create_test_vector_map(gvector.table.test_vector_name)
-
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(gvector))
- tests.addTests(doctest.DocTestSuite(gvector.abstract))
- tests.addTests(doctest.DocTestSuite(gvector.basic))
- tests.addTests(doctest.DocTestSuite(gvector.find))
- tests.addTests(doctest.DocTestSuite(gvector.geometry))
- tests.addTests(doctest.DocTestSuite(gvector.sql))
- tests.addTests(doctest.DocTestSuite(gvector.table))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/pygrass/vector/testsuite/test_pygrass_vector_doctests.py (from rev 74225, grass/trunk/lib/python/pygrass/vector/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/pygrass/vector/testsuite/test_pygrass_vector_doctests.py (rev 0)
+++ grass/trunk/lib/python/pygrass/vector/testsuite/test_pygrass_vector_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.pygrass.vector as gvector
+import grass.pygrass.utils as gutils
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+
+ from grass.pygrass import utils
+ utils.create_test_vector_map(gvector.test_vector_name)
+ utils.create_test_vector_map(gvector.abstract.test_vector_name)
+ utils.create_test_vector_map(gvector.geometry.test_vector_name)
+ utils.create_test_vector_map(gvector.find.test_vector_name)
+ utils.create_test_vector_map(gvector.table.test_vector_name)
+
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(gvector))
+ tests.addTests(doctest.DocTestSuite(gvector.abstract))
+ tests.addTests(doctest.DocTestSuite(gvector.basic))
+ tests.addTests(doctest.DocTestSuite(gvector.find))
+ tests.addTests(doctest.DocTestSuite(gvector.geometry))
+ tests.addTests(doctest.DocTestSuite(gvector.sql))
+ tests.addTests(doctest.DocTestSuite(gvector.table))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/script/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/script/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/script/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Tests checkers
-"""
-
-import doctest
-
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-import grass.script.array as garray
-
-
-# doctest does not allow changing the base classes of test case, skip test case
-# and test suite, so we need to create a new type which inherits from our class
-# and contains doctest's methods
-# the alternative is to copy 500 from doctest and change what is needed
-# (this might be necessary anyway because of the reports and stdout and stderr)
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- # TODO: this must be somewhere when doctest is called, not here
- # TODO: ultimate solution is not to use _ as a buildin in lib/python
- # for now it is the only place where it works
- grass.gunittest.utils.do_doctest_gettext_workaround()
- # this should be called at some top level
- tests.addTests(doctest.DocTestSuite(garray))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Deleted: grass/trunk/lib/python/script/testsuite/test_raster.py
===================================================================
--- grass/trunk/lib/python/script/testsuite/test_raster.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/script/testsuite/test_raster.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,45 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Created on Thu Feb 18 09:42:23 2016
-
- at author: lucadelu
-"""
-
-from grass.gunittest.case import TestCase
-from grass.gunittest.main import test
-
-import grass.script as gscript
-
-
-class TestRaster(TestCase):
- """Test raster functions"""
-
- raster = 'testrasterscript'
- region = gscript.region()
- coords = (region['e'] - 1, region['n'] - 1)
-
- @classmethod
- def setUpClass(cls):
- cls.runModule("r.mapcalc", expression="testrasterscript = 100",
- overwrite=True)
-
- @classmethod
- def tearDownClass(cls):
- cls.runModule("g.remove", type='raster', name='testrasterscript',
- flags='f')
-
- def test_raster_what(self):
- res = gscript.raster_what(self.raster, [self.coords])[0]
- self.assertEquals(int(res[self.raster]['value']), 100)
-
- res = gscript.raster_what(self.raster, [self.coords],
- localized=True)[0]
- self.assertEquals(int(res[self.raster][_('value')]), 100)
-
- def test_raster_info(self):
- res = gscript.raster_info(self.raster)
- self.assertEquals(str(res['cols']), str(self.region['cols']))
- self.assertEquals(str(res['north']), str(self.region['n']))
-
-if __name__ == '__main__':
- test()
Copied: grass/trunk/lib/python/script/testsuite/test_script_doctests.py (from rev 74225, grass/trunk/lib/python/script/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/script/testsuite/test_script_doctests.py (rev 0)
+++ grass/trunk/lib/python/script/testsuite/test_script_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+"""
+Tests checkers
+"""
+
+import doctest
+
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+import grass.script.array as garray
+
+
+# doctest does not allow changing the base classes of test case, skip test case
+# and test suite, so we need to create a new type which inherits from our class
+# and contains doctest's methods
+# the alternative is to copy 500 from doctest and change what is needed
+# (this might be necessary anyway because of the reports and stdout and stderr)
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ # TODO: this must be somewhere when doctest is called, not here
+ # TODO: ultimate solution is not to use _ as a buildin in lib/python
+ # for now it is the only place where it works
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ # this should be called at some top level
+ tests.addTests(doctest.DocTestSuite(garray))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Copied: grass/trunk/lib/python/script/testsuite/test_script_raster.py (from rev 74225, grass/trunk/lib/python/script/testsuite/test_raster.py)
===================================================================
--- grass/trunk/lib/python/script/testsuite/test_script_raster.py (rev 0)
+++ grass/trunk/lib/python/script/testsuite/test_script_raster.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Thu Feb 18 09:42:23 2016
+
+ at author: lucadelu
+"""
+
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+import grass.script as gscript
+
+
+class TestRaster(TestCase):
+ """Test raster functions"""
+
+ raster = 'testrasterscript'
+ region = gscript.region()
+ coords = (region['e'] - 1, region['n'] - 1)
+
+ @classmethod
+ def setUpClass(cls):
+ cls.runModule("r.mapcalc", expression="testrasterscript = 100",
+ overwrite=True)
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.runModule("g.remove", type='raster', name='testrasterscript',
+ flags='f')
+
+ def test_raster_what(self):
+ res = gscript.raster_what(self.raster, [self.coords])[0]
+ self.assertEquals(int(res[self.raster]['value']), 100)
+
+ res = gscript.raster_what(self.raster, [self.coords],
+ localized=True)[0]
+ self.assertEquals(int(res[self.raster][_('value')]), 100)
+
+ def test_raster_info(self):
+ res = gscript.raster_info(self.raster)
+ self.assertEquals(str(res['cols']), str(self.region['cols']))
+ self.assertEquals(str(res['north']), str(self.region['n']))
+
+if __name__ == '__main__':
+ test()
Deleted: grass/trunk/lib/python/temporal/testsuite/test_doctests.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/test_doctests.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/lib/python/temporal/testsuite/test_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-Temporal framework doctests
-"""
-
-import doctest
-import grass.temporal
-import grass.gunittest.case
-import grass.gunittest.main
-import grass.gunittest.utils
-
-
-doctest.DocFileCase = type('DocFileCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.DocFileCase.__dict__))
-doctest.SkipDocTestCase = type('SkipDocTestCase',
- (grass.gunittest.case.TestCase,),
- dict(doctest.SkipDocTestCase.__dict__))
-
-
-def load_tests(loader, tests, ignore):
- grass.gunittest.utils.do_doctest_gettext_workaround()
- tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_dataset))
- tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_map_dataset))
- tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_space_time_dataset))
- tests.addTests(doctest.DocTestSuite(grass.temporal.base))
- tests.addTests(doctest.DocTestSuite(grass.temporal.core))
- tests.addTests(doctest.DocTestSuite(grass.temporal.datetime_math))
- # Unexpected error here
- #tests.addTests(doctest.DocTestSuite(grass.temporal.list_stds))
- tests.addTests(doctest.DocTestSuite(grass.temporal.metadata))
- tests.addTests(doctest.DocTestSuite(grass.temporal.register))
- tests.addTests(doctest.DocTestSuite(grass.temporal.space_time_datasets))
- tests.addTests(doctest.DocTestSuite(grass.temporal.spatial_extent))
- tests.addTests(doctest.DocTestSuite(grass.temporal.spatial_topology_dataset_connector))
- tests.addTests(doctest.DocTestSuite(grass.temporal.spatio_temporal_relationships))
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_extent))
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_granularity))
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_topology_dataset_connector))
- # Algebra is still very experimental
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_algebra))
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster3d_algebra))
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster_algebra))
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster_base_algebra))
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_operator))
- tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_vector_algebra))
- tests.addTests(doctest.DocTestSuite(grass.temporal.c_libraries_interface))
- return tests
-
-
-if __name__ == '__main__':
- grass.gunittest.main.test()
Copied: grass/trunk/lib/python/temporal/testsuite/test_temporal_doctests.py (from rev 74225, grass/trunk/lib/python/temporal/testsuite/test_doctests.py)
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/test_temporal_doctests.py (rev 0)
+++ grass/trunk/lib/python/temporal/testsuite/test_temporal_doctests.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+"""
+Temporal framework doctests
+"""
+
+import doctest
+import grass.temporal
+import grass.gunittest.case
+import grass.gunittest.main
+import grass.gunittest.utils
+
+
+doctest.DocFileCase = type('DocFileCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.DocFileCase.__dict__))
+doctest.SkipDocTestCase = type('SkipDocTestCase',
+ (grass.gunittest.case.TestCase,),
+ dict(doctest.SkipDocTestCase.__dict__))
+
+
+def load_tests(loader, tests, ignore):
+ grass.gunittest.utils.do_doctest_gettext_workaround()
+ tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_dataset))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_map_dataset))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.abstract_space_time_dataset))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.base))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.core))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.datetime_math))
+ # Unexpected error here
+ #tests.addTests(doctest.DocTestSuite(grass.temporal.list_stds))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.metadata))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.register))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.space_time_datasets))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.spatial_extent))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.spatial_topology_dataset_connector))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.spatio_temporal_relationships))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_extent))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_granularity))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_topology_dataset_connector))
+ # Algebra is still very experimental
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_algebra))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster3d_algebra))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster_algebra))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_raster_base_algebra))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_operator))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.temporal_vector_algebra))
+ tests.addTests(doctest.DocTestSuite(grass.temporal.c_libraries_interface))
+ return tests
+
+
+if __name__ == '__main__':
+ grass.gunittest.main.test()
Deleted: grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py
===================================================================
--- grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,212 +0,0 @@
-"""Test t.rast.extract
-
-(C) 2014 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-import grass.pygrass.modules as pymod
-import subprocess
-from grass.gunittest.case import TestCase
-from grass.gunittest.gmodules import SimpleModule
-
-class TestRasterExtraction(TestCase):
-
- @classmethod
- def setUpClass(cls):
- """Initiate the temporal GIS and set the region
- """
- cls.use_temp_region()
- cls.runModule("g.gisenv", set="TGIS_USE_CURRENT_MAPSET=1")
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
- cls.runModule("r.mapcalc", expression="prec_1 = 100", overwrite=True)
- cls.runModule("r.mapcalc", expression="prec_2 = 200", overwrite=True)
- cls.runModule("r.mapcalc", expression="prec_3 = 300", overwrite=True)
- cls.runModule("r.mapcalc", expression="prec_4 = 400", overwrite=True)
- cls.runModule("r.mapcalc", expression="prec_5 = 500", overwrite=True)
- cls.runModule("r.mapcalc", expression="prec_6 = 600", overwrite=True)
-
- cls.runModule("t.create", type="strds", temporaltype="absolute",
- output="precip_abs1", title="A test",
- description="A test", overwrite=True)
- cls.runModule("t.register", flags="i", type="raster", input="precip_abs1",
- maps="prec_1,prec_2,prec_3,prec_4,prec_5,prec_6",
- start="2001-01-01", increment="3 months", overwrite=True)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region
- """
- cls.del_temp_region()
-
- def setUp(self):
- """Create input data for transient groundwater flow computation
- """
- # Use always the current mapset as temporal database
- self.runModule("r.mapcalc", expression="prec_1 = 100", overwrite=True)
- self.runModule("r.mapcalc", expression="prec_2 = 200", overwrite=True)
- self.runModule("r.mapcalc", expression="prec_3 = 300", overwrite=True)
- self.runModule("r.mapcalc", expression="prec_4 = 400", overwrite=True)
- self.runModule("r.mapcalc", expression="prec_5 = 500", overwrite=True)
- self.runModule("r.mapcalc", expression="prec_6 = 600", overwrite=True)
-
- self.runModule("t.create", type="strds", temporaltype="absolute",
- output="precip_abs1", title="A test", description="A test", overwrite=True)
- self.runModule("t.register", flags="i", type="raster", input="precip_abs1",
- maps="prec_1,prec_2,prec_3,prec_4,prec_5,prec_6",
- start="2001-01-01", increment="3 months", overwrite=True)
-
- def tearDown(self):
- """Remove generated data"""
- self.runModule("t.remove", flags="rf", type="strds",
- inputs="precip_abs2")
-
- def test_selection(self):
- """Perform a simple selection by datetime"""
- self.assertModule("t.rast.extract", input="precip_abs1", output="precip_abs2",
- where="start_time > '2001-06-01'")
-
- #self.assertModule("t.info", flags="g", input="precip_abs2")
-
- tinfo_string="""start_time='2001-07-01 00:00:00'
- end_time='2002-07-01 00:00:00'
- granularity='3 months'
- map_time=interval
- north=80.0
- south=0.0
- east=120.0
- west=0.0
- top=0.0
- bottom=0.0
- aggregation_type=None
- number_of_maps=4
- nsres_min=10.0
- nsres_max=10.0
- ewres_min=10.0
- ewres_max=10.0
- min_min=300.0
- min_max=600.0
- max_min=300.0
- max_max=600.0"""
-
- info = SimpleModule("t.info", flags="g", input="precip_abs2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
- def test_selection_and_expression(self):
- """Perform a selection by datetime and a r.mapcalc expression"""
- self.assertModule("t.rast.extract", input="precip_abs1", output="precip_abs2",
- where="start_time > '2001-06-01'",
- expression=" if(precip_abs1 > 400, precip_abs1, null())",
- basename="new_prec", nprocs=2, overwrite=True)
-
- #self.assertModule("t.info", flags="g", input="precip_abs2")
-
- tinfo_string="""start_time='2002-01-01 00:00:00'
- end_time='2002-07-01 00:00:00'
- granularity='3 months'
- map_time=interval
- north=80.0
- south=0.0
- east=120.0
- west=0.0
- top=0.0
- bottom=0.0
- aggregation_type=None
- number_of_maps=2
- nsres_min=10.0
- nsres_max=10.0
- ewres_min=10.0
- ewres_max=10.0
- min_min=500.0
- min_max=600.0
- max_min=500.0
- max_max=600.0"""
-
- info = SimpleModule("t.info", flags="g", input="precip_abs2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
- def test_expression_with_empty_maps(self):
- """Perform r.mapcalc expression and register empty maps"""
- self.assertModule("t.rast.extract", flags="n", input="precip_abs1", output="precip_abs2",
- expression=" if(precip_abs1 > 400, precip_abs1, null())",
- basename="new_prec", nprocs=2, overwrite=True)
-
- #self.assertModule("t.info", flags="g", input="precip_abs2")
-
- tinfo_string="""start_time='2001-01-01 00:00:00'
- end_time='2002-07-01 00:00:00'
- granularity='3 months'
- map_time=interval
- north=80.0
- south=0.0
- east=120.0
- west=0.0
- top=0.0
- bottom=0.0
- aggregation_type=None
- number_of_maps=6
- nsres_min=10.0
- nsres_max=10.0
- ewres_min=10.0
- ewres_max=10.0
- min_min=500.0
- min_max=600.0
- max_min=500.0
- max_max=600.0"""
-
- info = SimpleModule("t.info", flags="g", input="precip_abs2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
-
- def test_time_suffix_with_expression(self):
- """Perform extract with time suffix support and test if maps exists"""
- self.assertModule("t.rast.extract", flags="n", input="precip_abs1",
- output="precip_abs2", basename="new_prec",
- nprocs=2, overwrite=True, suffix="time",
- expression="if(precip_abs1 > 400, precip_abs1, null())")
- self.assertRasterExists('new_prec_2001_01_01T00_00_00')
- self.assertRasterDoesNotExist('new_prec_2001_01')
-
- def test_num_suffix_with_expression(self):
- """Perform extract with time suffix support and test if maps exists"""
- self.assertModule("t.rast.extract", flags="n", input="precip_abs1",
- output="precip_abs2", basename="new_prec",
- nprocs=2, overwrite=True, suffix='num%03',
- expression="if(precip_abs1 > 400, precip_abs1, null())")
- self.assertRasterExists('new_prec_001')
- self.assertRasterDoesNotExist('new_prec_00001')
-
-
-
-class TestRasterExtractionFails(TestCase):
-
- @classmethod
- def setUpClass(cls):
- """Initiate the temporal GIS and set the region
- """
- cls.use_temp_region()
- cls.runModule("g.gisenv", set="TGIS_USE_CURRENT_MAPSET=1")
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region
- """
- cls.del_temp_region()
-
- def test_error_handling(self):
- """Perform r.mapcalc expression and register empty maps"""
- # No input
- self.assertModuleFail("t.rast.extract", output="precip_abs2", basename="new_prec")
- # No output
- self.assertModuleFail("t.rast.extract", input="precip_abs1", basename="new_prec")
- # No basename
- self.assertModuleFail("t.rast.extract", input="precip_abs1", output="precip_abs2",
- expression=" if(precip_abs1 > 400, precip_abs1, null())")
-
-if __name__ == '__main__':
- from grass.gunittest.main import test
- test()
Copied: grass/trunk/temporal/t.rast.extract/testsuite/test_t_rast_extract.py (from rev 74225, grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py)
===================================================================
--- grass/trunk/temporal/t.rast.extract/testsuite/test_t_rast_extract.py (rev 0)
+++ grass/trunk/temporal/t.rast.extract/testsuite/test_t_rast_extract.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,212 @@
+"""Test t.rast.extract
+
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author Soeren Gebbert
+"""
+
+import grass.pygrass.modules as pymod
+import subprocess
+from grass.gunittest.case import TestCase
+from grass.gunittest.gmodules import SimpleModule
+
+class TestRasterExtraction(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Initiate the temporal GIS and set the region
+ """
+ cls.use_temp_region()
+ cls.runModule("g.gisenv", set="TGIS_USE_CURRENT_MAPSET=1")
+ cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
+ cls.runModule("r.mapcalc", expression="prec_1 = 100", overwrite=True)
+ cls.runModule("r.mapcalc", expression="prec_2 = 200", overwrite=True)
+ cls.runModule("r.mapcalc", expression="prec_3 = 300", overwrite=True)
+ cls.runModule("r.mapcalc", expression="prec_4 = 400", overwrite=True)
+ cls.runModule("r.mapcalc", expression="prec_5 = 500", overwrite=True)
+ cls.runModule("r.mapcalc", expression="prec_6 = 600", overwrite=True)
+
+ cls.runModule("t.create", type="strds", temporaltype="absolute",
+ output="precip_abs1", title="A test",
+ description="A test", overwrite=True)
+ cls.runModule("t.register", flags="i", type="raster", input="precip_abs1",
+ maps="prec_1,prec_2,prec_3,prec_4,prec_5,prec_6",
+ start="2001-01-01", increment="3 months", overwrite=True)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region
+ """
+ cls.del_temp_region()
+
+ def setUp(self):
+ """Create input data for transient groundwater flow computation
+ """
+ # Use always the current mapset as temporal database
+ self.runModule("r.mapcalc", expression="prec_1 = 100", overwrite=True)
+ self.runModule("r.mapcalc", expression="prec_2 = 200", overwrite=True)
+ self.runModule("r.mapcalc", expression="prec_3 = 300", overwrite=True)
+ self.runModule("r.mapcalc", expression="prec_4 = 400", overwrite=True)
+ self.runModule("r.mapcalc", expression="prec_5 = 500", overwrite=True)
+ self.runModule("r.mapcalc", expression="prec_6 = 600", overwrite=True)
+
+ self.runModule("t.create", type="strds", temporaltype="absolute",
+ output="precip_abs1", title="A test", description="A test", overwrite=True)
+ self.runModule("t.register", flags="i", type="raster", input="precip_abs1",
+ maps="prec_1,prec_2,prec_3,prec_4,prec_5,prec_6",
+ start="2001-01-01", increment="3 months", overwrite=True)
+
+ def tearDown(self):
+ """Remove generated data"""
+ self.runModule("t.remove", flags="rf", type="strds",
+ inputs="precip_abs2")
+
+ def test_selection(self):
+ """Perform a simple selection by datetime"""
+ self.assertModule("t.rast.extract", input="precip_abs1", output="precip_abs2",
+ where="start_time > '2001-06-01'")
+
+ #self.assertModule("t.info", flags="g", input="precip_abs2")
+
+ tinfo_string="""start_time='2001-07-01 00:00:00'
+ end_time='2002-07-01 00:00:00'
+ granularity='3 months'
+ map_time=interval
+ north=80.0
+ south=0.0
+ east=120.0
+ west=0.0
+ top=0.0
+ bottom=0.0
+ aggregation_type=None
+ number_of_maps=4
+ nsres_min=10.0
+ nsres_max=10.0
+ ewres_min=10.0
+ ewres_max=10.0
+ min_min=300.0
+ min_max=600.0
+ max_min=300.0
+ max_max=600.0"""
+
+ info = SimpleModule("t.info", flags="g", input="precip_abs2")
+ self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
+ def test_selection_and_expression(self):
+ """Perform a selection by datetime and a r.mapcalc expression"""
+ self.assertModule("t.rast.extract", input="precip_abs1", output="precip_abs2",
+ where="start_time > '2001-06-01'",
+ expression=" if(precip_abs1 > 400, precip_abs1, null())",
+ basename="new_prec", nprocs=2, overwrite=True)
+
+ #self.assertModule("t.info", flags="g", input="precip_abs2")
+
+ tinfo_string="""start_time='2002-01-01 00:00:00'
+ end_time='2002-07-01 00:00:00'
+ granularity='3 months'
+ map_time=interval
+ north=80.0
+ south=0.0
+ east=120.0
+ west=0.0
+ top=0.0
+ bottom=0.0
+ aggregation_type=None
+ number_of_maps=2
+ nsres_min=10.0
+ nsres_max=10.0
+ ewres_min=10.0
+ ewres_max=10.0
+ min_min=500.0
+ min_max=600.0
+ max_min=500.0
+ max_max=600.0"""
+
+ info = SimpleModule("t.info", flags="g", input="precip_abs2")
+ self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
+ def test_expression_with_empty_maps(self):
+ """Perform r.mapcalc expression and register empty maps"""
+ self.assertModule("t.rast.extract", flags="n", input="precip_abs1", output="precip_abs2",
+ expression=" if(precip_abs1 > 400, precip_abs1, null())",
+ basename="new_prec", nprocs=2, overwrite=True)
+
+ #self.assertModule("t.info", flags="g", input="precip_abs2")
+
+ tinfo_string="""start_time='2001-01-01 00:00:00'
+ end_time='2002-07-01 00:00:00'
+ granularity='3 months'
+ map_time=interval
+ north=80.0
+ south=0.0
+ east=120.0
+ west=0.0
+ top=0.0
+ bottom=0.0
+ aggregation_type=None
+ number_of_maps=6
+ nsres_min=10.0
+ nsres_max=10.0
+ ewres_min=10.0
+ ewres_max=10.0
+ min_min=500.0
+ min_max=600.0
+ max_min=500.0
+ max_max=600.0"""
+
+ info = SimpleModule("t.info", flags="g", input="precip_abs2")
+ self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
+
+ def test_time_suffix_with_expression(self):
+ """Perform extract with time suffix support and test if maps exists"""
+ self.assertModule("t.rast.extract", flags="n", input="precip_abs1",
+ output="precip_abs2", basename="new_prec",
+ nprocs=2, overwrite=True, suffix="time",
+ expression="if(precip_abs1 > 400, precip_abs1, null())")
+ self.assertRasterExists('new_prec_2001_01_01T00_00_00')
+ self.assertRasterDoesNotExist('new_prec_2001_01')
+
+ def test_num_suffix_with_expression(self):
+ """Perform extract with time suffix support and test if maps exists"""
+ self.assertModule("t.rast.extract", flags="n", input="precip_abs1",
+ output="precip_abs2", basename="new_prec",
+ nprocs=2, overwrite=True, suffix='num%03',
+ expression="if(precip_abs1 > 400, precip_abs1, null())")
+ self.assertRasterExists('new_prec_001')
+ self.assertRasterDoesNotExist('new_prec_00001')
+
+
+
+class TestRasterExtractionFails(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Initiate the temporal GIS and set the region
+ """
+ cls.use_temp_region()
+ cls.runModule("g.gisenv", set="TGIS_USE_CURRENT_MAPSET=1")
+ cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region
+ """
+ cls.del_temp_region()
+
+ def test_error_handling(self):
+ """Perform r.mapcalc expression and register empty maps"""
+ # No input
+ self.assertModuleFail("t.rast.extract", output="precip_abs2", basename="new_prec")
+ # No output
+ self.assertModuleFail("t.rast.extract", input="precip_abs1", basename="new_prec")
+ # No basename
+ self.assertModuleFail("t.rast.extract", input="precip_abs1", output="precip_abs2",
+ expression=" if(precip_abs1 > 400, precip_abs1, null())")
+
+if __name__ == '__main__':
+ from grass.gunittest.main import test
+ test()
Copied: grass/trunk/temporal/t.rast.univar/testsuite/test_t_rast_univar.py (from rev 74225, grass/trunk/temporal/t.rast.univar/testsuite/test_univar.py)
===================================================================
--- grass/trunk/temporal/t.rast.univar/testsuite/test_t_rast_univar.py (rev 0)
+++ grass/trunk/temporal/t.rast.univar/testsuite/test_t_rast_univar.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,155 @@
+"""Test t.rast.univar
+
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author Soeren Gebbert
+"""
+
+from grass.gunittest.case import TestCase
+from grass.gunittest.gmodules import SimpleModule
+
+class TestRasterUnivar(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Initiate the temporal GIS and set the region
+ """
+ cls.use_temp_region()
+ cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=1, res3=1)
+
+ cls.runModule("r.mapcalc", expression="a_1 = 100", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a_2 = 200", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a_3 = 300", overwrite=True)
+ cls.runModule("r.mapcalc", expression="a_4 = 400", overwrite=True)
+
+ cls.runModule("t.create", type="strds", temporaltype="absolute",
+ output="A", title="A test", description="A test",
+ overwrite=True)
+ cls.runModule("t.register", flags="i", type="raster", input="A",
+ maps="a_1,a_2,a_3,a_4", start="2001-01-01",
+ increment="3 months", overwrite=True)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region
+ """
+ cls.runModule("t.remove", flags="rf", type="strds",
+ inputs="A")
+ cls.del_temp_region()
+
+ def test_1(self):
+
+ t_rast_univar = SimpleModule("t.rast.univar", input="A",
+ where="start_time >= '2001-01-01'",
+ overwrite=True, verbose=True)
+ self.runModule("g.region", res=1)
+ self.assertModule(t_rast_univar)
+
+ univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
+a_1 at testing|2001-01-01 00:00:00|2001-04-01 00:00:00|100|100|100|100|0|0|0|960000|0|9600|9600
+a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|1920000|0|9600|9600
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600
+"""
+ for ref, res in zip(univar_text.split("\n"), t_rast_univar.outputs.stdout.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_2(self):
+
+ t_rast_univar = SimpleModule("t.rast.univar", input="A",
+ where="start_time >= '2001-03-01'",
+ overwrite=True, verbose=True)
+ self.runModule("g.region", res=1)
+ self.assertModule(t_rast_univar)
+
+ univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
+a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|1920000|0|9600|9600
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600
+"""
+ for ref, res in zip(univar_text.split("\n"), t_rast_univar.outputs.stdout.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_3(self):
+
+ t_rast_univar = SimpleModule("t.rast.univar", input="A",
+ where="start_time >= '2001-03-01'",
+ overwrite=True, verbose=True)
+ self.runModule("g.region", res=10)
+ self.assertModule(t_rast_univar)
+
+ univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
+a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|19200|0|96|96
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|28800|0|96|96
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|38400|0|96|96
+"""
+ for ref, res in zip(univar_text.split("\n"), t_rast_univar.outputs.stdout.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_4(self):
+
+ self.runModule("g.region", res=10)
+ self.assertModule("t.rast.univar", input="A", flags="r",
+ output="univar_output.txt",
+ where="start_time >= '2001-03-01'",
+ overwrite=True, verbose=True)
+
+ univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
+a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|1920000|0|9600|9600
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600
+"""
+ univar_output = open("univar_output.txt", "r").read()
+
+ for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_5(self):
+
+ self.runModule("g.region", res=10)
+ self.assertModule("t.rast.univar", input="A", flags="ru",
+ output="univar_output.txt",
+ where="start_time >= '2001-03-01'",
+ overwrite=True, verbose=True)
+
+ univar_text="""a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|1920000|0|9600|9600
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600
+"""
+ univar_output = open("univar_output.txt", "r").read()
+
+ for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_6_error_handling_empty_strds(self):
+ # Empty strds
+ self.assertModuleFail("t.rast.univar", input="A",
+ output="univar_output.txt",
+ where="start_time >= '2015-03-01'",
+ overwrite=True, verbose=True)
+
+ def test_7_error_handling_no_input(self):
+ # No input
+ self.assertModuleFail("t.rast.univar", output="out.txt")
+
+if __name__ == '__main__':
+ from grass.gunittest.main import test
+ test()
Deleted: grass/trunk/temporal/t.rast.univar/testsuite/test_univar.py
===================================================================
--- grass/trunk/temporal/t.rast.univar/testsuite/test_univar.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/temporal/t.rast.univar/testsuite/test_univar.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,155 +0,0 @@
-"""Test t.rast.univar
-
-(C) 2014 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-from grass.gunittest.case import TestCase
-from grass.gunittest.gmodules import SimpleModule
-
-class TestRasterUnivar(TestCase):
-
- @classmethod
- def setUpClass(cls):
- """Initiate the temporal GIS and set the region
- """
- cls.use_temp_region()
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=1, res3=1)
-
- cls.runModule("r.mapcalc", expression="a_1 = 100", overwrite=True)
- cls.runModule("r.mapcalc", expression="a_2 = 200", overwrite=True)
- cls.runModule("r.mapcalc", expression="a_3 = 300", overwrite=True)
- cls.runModule("r.mapcalc", expression="a_4 = 400", overwrite=True)
-
- cls.runModule("t.create", type="strds", temporaltype="absolute",
- output="A", title="A test", description="A test",
- overwrite=True)
- cls.runModule("t.register", flags="i", type="raster", input="A",
- maps="a_1,a_2,a_3,a_4", start="2001-01-01",
- increment="3 months", overwrite=True)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region
- """
- cls.runModule("t.remove", flags="rf", type="strds",
- inputs="A")
- cls.del_temp_region()
-
- def test_1(self):
-
- t_rast_univar = SimpleModule("t.rast.univar", input="A",
- where="start_time >= '2001-01-01'",
- overwrite=True, verbose=True)
- self.runModule("g.region", res=1)
- self.assertModule(t_rast_univar)
-
- univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
-a_1 at testing|2001-01-01 00:00:00|2001-04-01 00:00:00|100|100|100|100|0|0|0|960000|0|9600|9600
-a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|1920000|0|9600|9600
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600
-"""
- for ref, res in zip(univar_text.split("\n"), t_rast_univar.outputs.stdout.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_2(self):
-
- t_rast_univar = SimpleModule("t.rast.univar", input="A",
- where="start_time >= '2001-03-01'",
- overwrite=True, verbose=True)
- self.runModule("g.region", res=1)
- self.assertModule(t_rast_univar)
-
- univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
-a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|1920000|0|9600|9600
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600
-"""
- for ref, res in zip(univar_text.split("\n"), t_rast_univar.outputs.stdout.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_3(self):
-
- t_rast_univar = SimpleModule("t.rast.univar", input="A",
- where="start_time >= '2001-03-01'",
- overwrite=True, verbose=True)
- self.runModule("g.region", res=10)
- self.assertModule(t_rast_univar)
-
- univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
-a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|19200|0|96|96
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|28800|0|96|96
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|38400|0|96|96
-"""
- for ref, res in zip(univar_text.split("\n"), t_rast_univar.outputs.stdout.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_4(self):
-
- self.runModule("g.region", res=10)
- self.assertModule("t.rast.univar", input="A", flags="r",
- output="univar_output.txt",
- where="start_time >= '2001-03-01'",
- overwrite=True, verbose=True)
-
- univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
-a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|1920000|0|9600|9600
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600
-"""
- univar_output = open("univar_output.txt", "r").read()
-
- for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_5(self):
-
- self.runModule("g.region", res=10)
- self.assertModule("t.rast.univar", input="A", flags="ru",
- output="univar_output.txt",
- where="start_time >= '2001-03-01'",
- overwrite=True, verbose=True)
-
- univar_text="""a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|1920000|0|9600|9600
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600
-"""
- univar_output = open("univar_output.txt", "r").read()
-
- for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_6_error_handling_empty_strds(self):
- # Empty strds
- self.assertModuleFail("t.rast.univar", input="A",
- output="univar_output.txt",
- where="start_time >= '2015-03-01'",
- overwrite=True, verbose=True)
-
- def test_7_error_handling_no_input(self):
- # No input
- self.assertModuleFail("t.rast.univar", output="out.txt")
-
-if __name__ == '__main__':
- from grass.gunittest.main import test
- test()
Deleted: grass/trunk/temporal/t.rast3d.extract/testsuite/test_extract.py
===================================================================
--- grass/trunk/temporal/t.rast3d.extract/testsuite/test_extract.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/temporal/t.rast3d.extract/testsuite/test_extract.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,163 +0,0 @@
-"""Test t.rast3d.extract
-
-(C) 2014 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
-:authors: Soeren Gebbert
-"""
-
-import grass.pygrass.modules as pymod
-import subprocess
-from grass.gunittest.case import TestCase
-from grass.gunittest.gmodules import SimpleModule
-
-class TestRaster3dExtraction(TestCase):
-
- @classmethod
- def setUpClass(cls):
- """Initiate the temporal GIS and set the region
- """
- cls.use_temp_region()
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region
- """
- cls.del_temp_region()
-
- def setUp(self):
- """Create input data for transient groundwater flow computation
- """
- # Use always the current mapset as temporal database
- self.runModule("r3.mapcalc", expression="a1 = 100", overwrite=True)
- self.runModule("r3.mapcalc", expression="a2 = 200", overwrite=True)
- self.runModule("r3.mapcalc", expression="a3 = 300", overwrite=True)
- self.runModule("r3.mapcalc", expression="a4 = 400", overwrite=True)
- self.runModule("r3.mapcalc", expression="a5 = 500", overwrite=True)
- self.runModule("r3.mapcalc", expression="a6 = 600", overwrite=True)
-
- self.runModule("t.create", type="str3ds", temporaltype="absolute",
- output="A", title="A test", description="A test", overwrite=True)
- self.runModule("t.register", flags="i", type="raster_3d", input="A",
- maps="a1,a2,a3,a4,a5,a6",
- start="2001-01-01", increment="3 months", overwrite=True)
-
- def tearDown(self):
- """Remove generated data"""
- self.runModule("t.remove", flags="rf", type="str3ds",
- inputs="A,B")
-
- def test_selection(self):
- """Perform a simple selection by datetime"""
- self.assertModule("t.rast3d.extract", input="A", output="B",
- where="start_time > '2001-06-01'")
-
- #self.assertModule("t.info", flags="g", input="B")
-
- tinfo_string="""start_time='2001-07-01 00:00:00'
- end_time='2002-07-01 00:00:00'
- granularity='3 months'
- map_time=interval
- aggregation_type=None
- number_of_maps=4
- min_min=300.0
- min_max=600.0
- max_min=300.0
- max_max=600.0"""
-
- info = SimpleModule("t.info", flags="g", type="str3ds", input="B")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
- def test_selection_and_expression(self):
- """Perform a selection by datetime and a r3.mapcalc expression"""
- self.assertModule("t.rast3d.extract", input="A", output="B",
- where="start_time > '2001-06-01'",
- expression=" if(A > 400, A, null())",
- basename="b", nprocs=2, overwrite=True)
-
- #self.assertModule("t.info", flags="g", input="B")
-
- tinfo_string="""start_time='2002-01-01 00:00:00'
- end_time='2002-07-01 00:00:00'
- granularity='3 months'
- map_time=interval
- aggregation_type=None
- number_of_maps=2
- min_min=500.0
- min_max=600.0
- max_min=500.0
- max_max=600.0"""
-
- info = SimpleModule("t.info", flags="g", type="str3ds", input="B")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
- def test_expression_with_empty_maps(self):
- """Perform r3.mapcalc expression and register empty maps"""
- self.assertModule("t.rast3d.extract", flags="n", input="A", output="B",
- expression=" if(A > 400, A, null())",
- basename="b", nprocs=2, overwrite=True)
-
- #self.assertModule("t.info", flags="g", input="B")
-
- tinfo_string="""start_time='2001-01-01 00:00:00'
- end_time='2002-07-01 00:00:00'
- granularity='3 months'
- map_time=interval
- aggregation_type=None
- number_of_maps=6
- min_min=500.0
- min_max=600.0
- max_min=500.0
- max_max=600.0"""
-
- info = SimpleModule("t.info", flags="g", type="str3ds", input="B")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
- def test_time_suffix_with_expression(self):
- """Perform extract with time suffix support and test if maps exists"""
- self.assertModule("t.rast3d.extract", flags="n", input="A", nprocs=2,
- output="B", basename="b", overwrite=True,
- suffix="time", expression="if(A > 400, A, null())")
- self.assertRaster3dExists('b_2001_01_01T00_00_00')
- self.assertRaster3dDoesNotExist('b_2001_01')
-
- def test_num_suffix_with_expression(self):
- """Perform extract with time suffix support and test if maps exists"""
- self.assertModule("t.rast3d.extract", flags="n", input="A", nprocs=2,
- output="B", basename="b", overwrite=True,
- suffix='num%03', expression="if(A > 400, A, null())")
- self.assertRaster3dExists('b_001')
- self.assertRaster3dDoesNotExist('b_00001')
-
-
-class TestRaster3dExtractionFails(TestCase):
-
- @classmethod
- def setUpClass(cls):
- """Initiate the temporal GIS and set the region
- """
- cls.use_temp_region()
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region
- """
- cls.del_temp_region()
-
- def test_error_handling(self):
- """Perform r3.mapcalc expression and register empty maps"""
- # No input
- self.assertModuleFail("t.rast3d.extract", output="B", basename="b")
- # No output
- self.assertModuleFail("t.rast3d.extract", input="A", basename="b")
- # No basename
- self.assertModuleFail("t.rast3d.extract", input="A", output="B",
- expression=" if(A > 400, A, null())")
-
-if __name__ == '__main__':
- from grass.gunittest.main import test
- test()
Copied: grass/trunk/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py (from rev 74225, grass/trunk/temporal/t.rast3d.extract/testsuite/test_extract.py)
===================================================================
--- grass/trunk/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py (rev 0)
+++ grass/trunk/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,163 @@
+"""Test t.rast3d.extract
+
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+:authors: Soeren Gebbert
+"""
+
+import grass.pygrass.modules as pymod
+import subprocess
+from grass.gunittest.case import TestCase
+from grass.gunittest.gmodules import SimpleModule
+
+class TestRaster3dExtraction(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Initiate the temporal GIS and set the region
+ """
+ cls.use_temp_region()
+ cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region
+ """
+ cls.del_temp_region()
+
+ def setUp(self):
+ """Create input data for transient groundwater flow computation
+ """
+ # Use always the current mapset as temporal database
+ self.runModule("r3.mapcalc", expression="a1 = 100", overwrite=True)
+ self.runModule("r3.mapcalc", expression="a2 = 200", overwrite=True)
+ self.runModule("r3.mapcalc", expression="a3 = 300", overwrite=True)
+ self.runModule("r3.mapcalc", expression="a4 = 400", overwrite=True)
+ self.runModule("r3.mapcalc", expression="a5 = 500", overwrite=True)
+ self.runModule("r3.mapcalc", expression="a6 = 600", overwrite=True)
+
+ self.runModule("t.create", type="str3ds", temporaltype="absolute",
+ output="A", title="A test", description="A test", overwrite=True)
+ self.runModule("t.register", flags="i", type="raster_3d", input="A",
+ maps="a1,a2,a3,a4,a5,a6",
+ start="2001-01-01", increment="3 months", overwrite=True)
+
+ def tearDown(self):
+ """Remove generated data"""
+ self.runModule("t.remove", flags="rf", type="str3ds",
+ inputs="A,B")
+
+ def test_selection(self):
+ """Perform a simple selection by datetime"""
+ self.assertModule("t.rast3d.extract", input="A", output="B",
+ where="start_time > '2001-06-01'")
+
+ #self.assertModule("t.info", flags="g", input="B")
+
+ tinfo_string="""start_time='2001-07-01 00:00:00'
+ end_time='2002-07-01 00:00:00'
+ granularity='3 months'
+ map_time=interval
+ aggregation_type=None
+ number_of_maps=4
+ min_min=300.0
+ min_max=600.0
+ max_min=300.0
+ max_max=600.0"""
+
+ info = SimpleModule("t.info", flags="g", type="str3ds", input="B")
+ self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
+ def test_selection_and_expression(self):
+ """Perform a selection by datetime and a r3.mapcalc expression"""
+ self.assertModule("t.rast3d.extract", input="A", output="B",
+ where="start_time > '2001-06-01'",
+ expression=" if(A > 400, A, null())",
+ basename="b", nprocs=2, overwrite=True)
+
+ #self.assertModule("t.info", flags="g", input="B")
+
+ tinfo_string="""start_time='2002-01-01 00:00:00'
+ end_time='2002-07-01 00:00:00'
+ granularity='3 months'
+ map_time=interval
+ aggregation_type=None
+ number_of_maps=2
+ min_min=500.0
+ min_max=600.0
+ max_min=500.0
+ max_max=600.0"""
+
+ info = SimpleModule("t.info", flags="g", type="str3ds", input="B")
+ self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
+ def test_expression_with_empty_maps(self):
+ """Perform r3.mapcalc expression and register empty maps"""
+ self.assertModule("t.rast3d.extract", flags="n", input="A", output="B",
+ expression=" if(A > 400, A, null())",
+ basename="b", nprocs=2, overwrite=True)
+
+ #self.assertModule("t.info", flags="g", input="B")
+
+ tinfo_string="""start_time='2001-01-01 00:00:00'
+ end_time='2002-07-01 00:00:00'
+ granularity='3 months'
+ map_time=interval
+ aggregation_type=None
+ number_of_maps=6
+ min_min=500.0
+ min_max=600.0
+ max_min=500.0
+ max_max=600.0"""
+
+ info = SimpleModule("t.info", flags="g", type="str3ds", input="B")
+ self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
+ def test_time_suffix_with_expression(self):
+ """Perform extract with time suffix support and test if maps exists"""
+ self.assertModule("t.rast3d.extract", flags="n", input="A", nprocs=2,
+ output="B", basename="b", overwrite=True,
+ suffix="time", expression="if(A > 400, A, null())")
+ self.assertRaster3dExists('b_2001_01_01T00_00_00')
+ self.assertRaster3dDoesNotExist('b_2001_01')
+
+ def test_num_suffix_with_expression(self):
+ """Perform extract with time suffix support and test if maps exists"""
+ self.assertModule("t.rast3d.extract", flags="n", input="A", nprocs=2,
+ output="B", basename="b", overwrite=True,
+ suffix='num%03', expression="if(A > 400, A, null())")
+ self.assertRaster3dExists('b_001')
+ self.assertRaster3dDoesNotExist('b_00001')
+
+
+class TestRaster3dExtractionFails(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Initiate the temporal GIS and set the region
+ """
+ cls.use_temp_region()
+ cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region
+ """
+ cls.del_temp_region()
+
+ def test_error_handling(self):
+ """Perform r3.mapcalc expression and register empty maps"""
+ # No input
+ self.assertModuleFail("t.rast3d.extract", output="B", basename="b")
+ # No output
+ self.assertModuleFail("t.rast3d.extract", input="A", basename="b")
+ # No basename
+ self.assertModuleFail("t.rast3d.extract", input="A", output="B",
+ expression=" if(A > 400, A, null())")
+
+if __name__ == '__main__':
+ from grass.gunittest.main import test
+ test()
Copied: grass/trunk/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py (from rev 74225, grass/trunk/temporal/t.rast3d.univar/testsuite/test_univar.py)
===================================================================
--- grass/trunk/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py (rev 0)
+++ grass/trunk/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,133 @@
+"""Test t.rast.univar
+
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author Soeren Gebbert
+"""
+
+from grass.gunittest.case import TestCase
+from grass.gunittest.gmodules import SimpleModule
+
+
+class TestRasterUnivar(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Initiate the temporal GIS and set the region
+ """
+ cls.use_temp_region()
+ cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=1, res3=1)
+
+ cls.runModule("r3.mapcalc", expression="a_1 = 100", overwrite=True)
+ cls.runModule("r3.mapcalc", expression="a_2 = 200", overwrite=True)
+ cls.runModule("r3.mapcalc", expression="a_3 = 300", overwrite=True)
+ cls.runModule("r3.mapcalc", expression="a_4 = 400", overwrite=True)
+
+ cls.runModule("t.create", type="str3ds", temporaltype="absolute",
+ output="A", title="A test", description="A test",
+ overwrite=True)
+ cls.runModule("t.register", flags="i", type="raster_3d", input="A",
+ maps="a_1,a_2,a_3,a_4", start="2001-01-01",
+ increment="3 months", overwrite=True)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region
+ """
+ cls.runModule("t.remove", flags="rf", type="str3ds",
+ inputs="A")
+ cls.del_temp_region()
+
+ def test_1(self):
+
+ t_rast3d_univar = SimpleModule("t.rast3d.univar", input="A",
+ where="start_time >= '2001-01-01'",
+ overwrite=True, verbose=True)
+ self.assertModule(t_rast3d_univar)
+
+ univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
+a_1 at testing|2001-01-01 00:00:00|2001-04-01 00:00:00|100|100|100|100|0|0|0|48000000|0|480000|480000
+a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|96000000|0|480000|480000
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000
+"""
+ for ref, res in zip(univar_text.split("\n"), t_rast3d_univar.outputs.stdout.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_2(self):
+
+ t_rast3d_univar = SimpleModule("t.rast3d.univar", input="A",
+ where="start_time >= '2001-03-01'",
+ overwrite=True, verbose=True)
+ self.assertModule(t_rast3d_univar)
+
+ univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
+a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|96000000|0|480000|480000
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000
+"""
+ for ref, res in zip(univar_text.split("\n"), t_rast3d_univar.outputs.stdout.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_3(self):
+
+ self.assertModule("t.rast3d.univar", input="A",
+ output="univar_output.txt",
+ where="start_time >= '2001-03-01'",
+ overwrite=True, verbose=True)
+
+ univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
+a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|96000000|0|480000|480000
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000
+"""
+ univar_output = open("univar_output.txt", "r").read()
+
+ for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_4(self):
+
+ self.assertModule("t.rast3d.univar", input="A",
+ output="univar_output.txt", flags="s",
+ where="start_time >= '2001-03-01'",
+ overwrite=True, verbose=True)
+
+ univar_text="""a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|96000000|0|480000|480000
+a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000
+a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000
+"""
+ univar_output = open("univar_output.txt", "r").read()
+
+ for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")):
+ if ref and res:
+ ref_line = ref.split("|", 1)[1]
+ res_line = res.split("|", 1)[1]
+ self.assertLooksLike(ref_line, res_line)
+
+ def test_5_error_handling_empty_strds(self):
+ # Empty str3ds
+ self.assertModuleFail("t.rast3d.univar", input="A",
+ output="univar_output.txt",
+ where="start_time >= '2015-03-01'",
+ overwrite=True, verbose=True)
+
+ def test_6_error_handling_no_input(self):
+ # No input
+ self.assertModuleFail("t.rast3d.univar", output="out.txt")
+
+if __name__ == '__main__':
+ from grass.gunittest.main import test
+ test()
Deleted: grass/trunk/temporal/t.rast3d.univar/testsuite/test_univar.py
===================================================================
--- grass/trunk/temporal/t.rast3d.univar/testsuite/test_univar.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/temporal/t.rast3d.univar/testsuite/test_univar.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,133 +0,0 @@
-"""Test t.rast.univar
-
-(C) 2014 by the GRASS Development Team
-This program is free software under the GNU General Public
-License (>=v2). Read the file COPYING that comes with GRASS
-for details.
-
- at author Soeren Gebbert
-"""
-
-from grass.gunittest.case import TestCase
-from grass.gunittest.gmodules import SimpleModule
-
-
-class TestRasterUnivar(TestCase):
-
- @classmethod
- def setUpClass(cls):
- """Initiate the temporal GIS and set the region
- """
- cls.use_temp_region()
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=1, res3=1)
-
- cls.runModule("r3.mapcalc", expression="a_1 = 100", overwrite=True)
- cls.runModule("r3.mapcalc", expression="a_2 = 200", overwrite=True)
- cls.runModule("r3.mapcalc", expression="a_3 = 300", overwrite=True)
- cls.runModule("r3.mapcalc", expression="a_4 = 400", overwrite=True)
-
- cls.runModule("t.create", type="str3ds", temporaltype="absolute",
- output="A", title="A test", description="A test",
- overwrite=True)
- cls.runModule("t.register", flags="i", type="raster_3d", input="A",
- maps="a_1,a_2,a_3,a_4", start="2001-01-01",
- increment="3 months", overwrite=True)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region
- """
- cls.runModule("t.remove", flags="rf", type="str3ds",
- inputs="A")
- cls.del_temp_region()
-
- def test_1(self):
-
- t_rast3d_univar = SimpleModule("t.rast3d.univar", input="A",
- where="start_time >= '2001-01-01'",
- overwrite=True, verbose=True)
- self.assertModule(t_rast3d_univar)
-
- univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
-a_1 at testing|2001-01-01 00:00:00|2001-04-01 00:00:00|100|100|100|100|0|0|0|48000000|0|480000|480000
-a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|96000000|0|480000|480000
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000
-"""
- for ref, res in zip(univar_text.split("\n"), t_rast3d_univar.outputs.stdout.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_2(self):
-
- t_rast3d_univar = SimpleModule("t.rast3d.univar", input="A",
- where="start_time >= '2001-03-01'",
- overwrite=True, verbose=True)
- self.assertModule(t_rast3d_univar)
-
- univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
-a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|96000000|0|480000|480000
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000
-"""
- for ref, res in zip(univar_text.split("\n"), t_rast3d_univar.outputs.stdout.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_3(self):
-
- self.assertModule("t.rast3d.univar", input="A",
- output="univar_output.txt",
- where="start_time >= '2001-03-01'",
- overwrite=True, verbose=True)
-
- univar_text="""id|start|end|mean|min|max|mean_of_abs|stddev|variance|coeff_var|sum|null_cells|cells|non_null_cells
-a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|96000000|0|480000|480000
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000
-"""
- univar_output = open("univar_output.txt", "r").read()
-
- for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_4(self):
-
- self.assertModule("t.rast3d.univar", input="A",
- output="univar_output.txt", flags="s",
- where="start_time >= '2001-03-01'",
- overwrite=True, verbose=True)
-
- univar_text="""a_2 at testing|2001-04-01 00:00:00|2001-07-01 00:00:00|200|200|200|200|0|0|0|96000000|0|480000|480000
-a_3 at testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000
-a_4 at testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000
-"""
- univar_output = open("univar_output.txt", "r").read()
-
- for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")):
- if ref and res:
- ref_line = ref.split("|", 1)[1]
- res_line = res.split("|", 1)[1]
- self.assertLooksLike(ref_line, res_line)
-
- def test_5_error_handling_empty_strds(self):
- # Empty str3ds
- self.assertModuleFail("t.rast3d.univar", input="A",
- output="univar_output.txt",
- where="start_time >= '2015-03-01'",
- overwrite=True, verbose=True)
-
- def test_6_error_handling_no_input(self):
- # No input
- self.assertModuleFail("t.rast3d.univar", output="out.txt")
-
-if __name__ == '__main__':
- from grass.gunittest.main import test
- test()
Deleted: grass/trunk/vector/v.extract/testsuite/test_extract.py
===================================================================
--- grass/trunk/vector/v.extract/testsuite/test_extract.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/vector/v.extract/testsuite/test_extract.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,94 +0,0 @@
-"""
-Name: v.extract test
-Purpose: Tests v.extract and its flags/options.
-
-Author: Sunveer Singh, Google Code-in 2017
-Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team
-Licence: This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-"""
-import os
-from grass.gunittest.case import TestCase
-from grass.gunittest.gmodules import SimpleModule
-from grass.script.core import read_command
-
-TABLE_1="""cat|MAJORRDS_|ROAD_NAME|MULTILANE|PROPYEAR|OBJECTID|SHAPE_LEN
-1|1|NC-50|no|0|1|4825.369405
-2|2|NC-50|no|0|2|14392.589058
-3|3|NC-98|no|0|3|3212.981242
-4|4|NC-50|no|0|4|13391.907552
-"""
-TABLE_2="""cat|onemap_pro|PERIMETER|GEOL250_|GEOL250_ID|GEO_NAME|SHAPE_area|SHAPE_len
-1|963738.75|4083.97998|2|1|Zml|963738.608571|4083.979839
-2|22189124|26628.261719|3|2|Zmf|22189123.2296|26628.261112
-3|579286.875|3335.55835|4|3|Zml|579286.829631|3335.557182
-4|20225526|33253|5|4|Zml|20225526.6368|33253.000508
-5|450650720|181803.765625|6|5|Ybgg|450650731.029|181803.776199
-"""
-
-TABLE_3="""cat|MAJORRDS_|ROAD_NAME|MULTILANE|PROPYEAR|OBJECTID|SHAPE_LEN
-1|1|NC-50|no|0|1|4825.369405
-2|2|NC-50|no|0|2|14392.589058
-3|3|NC-98|no|0|3|3212.981242
-4|4|NC-50|no|0|4|13391.907552
-5|5|NC-98|no|0|5|7196.001495
-6|6||no|0|6|10185.513951
-7|7|US-1|yes|0|7|13655.438596
-8|8||no|0|8|797.901095
-9|9|NC-98|no|0|9|14772.176241
-"""
-class TestRasterreport(TestCase):
- input="roadsmajor"
- output="testoutput"
- geology='geology'
-
- @classmethod
- def setUpClass(cls):
- cls.use_temp_region()
-
- @classmethod
- def tearDownClass(cls):
- cls.del_temp_region()
-
- def tearDown(cls):
- cls.runModule('g.remove', flags='f', type='vector', name=cls.output)
-
- def test_flagd(self):
- """Testing flag d """
- self.assertModule('v.extract', input=self.input, output=self.output, cats="1,2,3,4")
- category = read_command('v.db.select', map=self.output,
- separator='pipe')
- self.assertEqual(first=TABLE_1.replace('\n', os.linesep),
- second=category,
- msg="Attribute table has wrong entries")
-
- def test_cats2(self):
- """Testing cats=2 """
- self.assertModule('v.extract', input=self.geology, output=self.output, flags='d', cats="1,2,3,4,5")
- category = read_command('v.db.select', map=self.output,
- separator='pipe')
- self.assertEqual(first=TABLE_2.replace('\n', os.linesep),
- second=category,
- msg="Attribute table has wrong entries")
-
- def test_flagt(self):
- """Testing Falg T"""
- self.assertModule('v.extract', input=self.input, output=self.output, flags='t', cats=1 )
-
- def test_flatr(self):
- """Testing flag r """
- self.assertModule('v.extract', input=self.geology, output=self.output, flags='r', cats=1 )
-
- def test_where(self):
- """Testing where"""
- self.assertModule('v.extract', input=self.input, output=self.output, flags='d',
- where="cat < 10")
- category = read_command('v.db.select', map=self.output,
- separator='pipe')
- self.assertEqual(first=TABLE_3.replace('\n', os.linesep),
- second=category,
- msg="Attribute table has wrong entries")
-if __name__ == '__main__':
- from grass.gunittest.main import test
- test()
Copied: grass/trunk/vector/v.extract/testsuite/test_v_extract.py (from rev 74225, grass/trunk/vector/v.extract/testsuite/test_extract.py)
===================================================================
--- grass/trunk/vector/v.extract/testsuite/test_v_extract.py (rev 0)
+++ grass/trunk/vector/v.extract/testsuite/test_v_extract.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,94 @@
+"""
+Name: v.extract test
+Purpose: Tests v.extract and its flags/options.
+
+Author: Sunveer Singh, Google Code-in 2017
+Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team
+Licence: This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+"""
+import os
+from grass.gunittest.case import TestCase
+from grass.gunittest.gmodules import SimpleModule
+from grass.script.core import read_command
+
+TABLE_1="""cat|MAJORRDS_|ROAD_NAME|MULTILANE|PROPYEAR|OBJECTID|SHAPE_LEN
+1|1|NC-50|no|0|1|4825.369405
+2|2|NC-50|no|0|2|14392.589058
+3|3|NC-98|no|0|3|3212.981242
+4|4|NC-50|no|0|4|13391.907552
+"""
+TABLE_2="""cat|onemap_pro|PERIMETER|GEOL250_|GEOL250_ID|GEO_NAME|SHAPE_area|SHAPE_len
+1|963738.75|4083.97998|2|1|Zml|963738.608571|4083.979839
+2|22189124|26628.261719|3|2|Zmf|22189123.2296|26628.261112
+3|579286.875|3335.55835|4|3|Zml|579286.829631|3335.557182
+4|20225526|33253|5|4|Zml|20225526.6368|33253.000508
+5|450650720|181803.765625|6|5|Ybgg|450650731.029|181803.776199
+"""
+
+TABLE_3="""cat|MAJORRDS_|ROAD_NAME|MULTILANE|PROPYEAR|OBJECTID|SHAPE_LEN
+1|1|NC-50|no|0|1|4825.369405
+2|2|NC-50|no|0|2|14392.589058
+3|3|NC-98|no|0|3|3212.981242
+4|4|NC-50|no|0|4|13391.907552
+5|5|NC-98|no|0|5|7196.001495
+6|6||no|0|6|10185.513951
+7|7|US-1|yes|0|7|13655.438596
+8|8||no|0|8|797.901095
+9|9|NC-98|no|0|9|14772.176241
+"""
+class TestRasterreport(TestCase):
+ input="roadsmajor"
+ output="testoutput"
+ geology='geology'
+
+ @classmethod
+ def setUpClass(cls):
+ cls.use_temp_region()
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.del_temp_region()
+
+ def tearDown(cls):
+ cls.runModule('g.remove', flags='f', type='vector', name=cls.output)
+
+ def test_flagd(self):
+ """Testing flag d """
+ self.assertModule('v.extract', input=self.input, output=self.output, cats="1,2,3,4")
+ category = read_command('v.db.select', map=self.output,
+ separator='pipe')
+ self.assertEqual(first=TABLE_1.replace('\n', os.linesep),
+ second=category,
+ msg="Attribute table has wrong entries")
+
+ def test_cats2(self):
+ """Testing cats=2 """
+ self.assertModule('v.extract', input=self.geology, output=self.output, flags='d', cats="1,2,3,4,5")
+ category = read_command('v.db.select', map=self.output,
+ separator='pipe')
+ self.assertEqual(first=TABLE_2.replace('\n', os.linesep),
+ second=category,
+ msg="Attribute table has wrong entries")
+
+ def test_flagt(self):
+ """Testing Falg T"""
+ self.assertModule('v.extract', input=self.input, output=self.output, flags='t', cats=1 )
+
+ def test_flatr(self):
+ """Testing flag r """
+ self.assertModule('v.extract', input=self.geology, output=self.output, flags='r', cats=1 )
+
+ def test_where(self):
+ """Testing where"""
+ self.assertModule('v.extract', input=self.input, output=self.output, flags='d',
+ where="cat < 10")
+ category = read_command('v.db.select', map=self.output,
+ separator='pipe')
+ self.assertEqual(first=TABLE_3.replace('\n', os.linesep),
+ second=category,
+ msg="Attribute table has wrong entries")
+if __name__ == '__main__':
+ from grass.gunittest.main import test
+ test()
Deleted: grass/trunk/vector/v.in.lidar/testsuite/basic_test.py
===================================================================
--- grass/trunk/vector/v.in.lidar/testsuite/basic_test.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/vector/v.in.lidar/testsuite/basic_test.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,68 +0,0 @@
-"""
-Name: decimation_test
-Purpose: v.in.lidar decimation test
-
-Author: Vaclav Petras
-Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
-Licence: This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-"""
-
-import os
-from grass.gunittest.case import TestCase
-from grass.gunittest.main import test
-
-
-class BasicTest(TestCase):
- """Test case for watershed module
-
- This tests expects v.random and v.out.lidar to work properly.
- """
-
- # Setup variables to be used for outputs
- vector_points = 'vinlidar_basic_original'
- imported_points = 'vinlidar_basic_imported'
- las_file = 'vinlidar_basic_points.las'
- npoints = 300
-
- @classmethod
- def setUpClass(cls):
- """Ensures expected computational region and generated data"""
- cls.use_temp_region()
- cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
- cls.runModule('v.random', flags='zb', output=cls.vector_points,
- npoints=cls.npoints, zmin=200, zmax=500, seed=100)
- cls.runModule('v.out.lidar', input=cls.vector_points,
- output=cls.las_file)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region and generated data"""
- cls.runModule('g.remove', flags='f', type='vector',
- name=cls.vector_points)
- if os.path.isfile(cls.las_file):
- os.remove(cls.las_file)
- cls.del_temp_region()
-
- def tearDown(self):
- """Remove the outputs created by the import
-
- This is executed after each test run.
- """
- self.runModule('g.remove', flags='f', type='vector',
- name=self.imported_points)
-
- def test_output_identical(self):
- """Test to see if the standard outputs are created"""
- self.assertModule('v.in.lidar', input=self.las_file,
- output=self.imported_points, flags='bt')
- self.assertVectorExists(self.imported_points)
- self.assertVectorEqualsVector(
- actual=self.imported_points,
- reference=self.vector_points,
- digits=2, precision=.01)
-
-
-if __name__ == '__main__':
- test()
Deleted: grass/trunk/vector/v.in.lidar/testsuite/filter_test.py
===================================================================
--- grass/trunk/vector/v.in.lidar/testsuite/filter_test.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/vector/v.in.lidar/testsuite/filter_test.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,208 +0,0 @@
-"""
-Name: decimation_test
-Purpose: v.in.lidar decimation test
-
-Author: Vaclav Petras
-Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
-Licence: This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-"""
-
-import os
-from grass.gunittest.case import TestCase
-from grass.gunittest.main import test
-
-
-POINTS = """\
-17.46938776,18.67346939,143,1,1,2
-20.93877551,17.44897959,125,1,1,2
-18.89795918,14.18367347,130,1,1,3
-15.91836735,10.67346939,126,1,1,3
-21.26530612,11.04081633,128,1,2,3
-22.24489796,13.89795918,123,2,2,3
-23.79591837,17.12244898,151,1,2,3
-17.2244898,16.34693878,124,2,2,4
-17.14285714,14.10204082,134,1,3,4
-19.87755102,11.81632653,146,2,3,4
-18.48979592,11.48979592,140.6,2,3,4
-21.26530612,15.73469388,147,3,3,5
-21.18367347,19.32653061,138,1,3,5
-23.91836735,18.83673469,144,2,3,5
-23.51020408,13.65306122,143,3,3,5
-23.55102041,11.32653061,123,1,4,5
-18.41009273,14.51618034,140.4,2,4,5
-22.13996161,17.2278263,147,3,4,5
-21.41013052,11.05432488,132,4,4,5
-"""
-
-
-class FilterTest(TestCase):
- """Test case for filter and selection options
-
- This tests expects v.random and v.out.lidar to work properly.
- """
-
- # Setup variables to be used for outputs
- vector_points = 'vinlidar_filters_original'
- imported_points = 'vinlidar_filters_imported'
- las_file = 'vinlidar_filters_points.las'
- npoints = 300
-
- @classmethod
- def setUpClass(cls):
- """Ensures expected computational region and generated data"""
- cls.use_temp_region()
- cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
- cls.runModule('v.in.ascii', input='-', stdin_=POINTS,
- flags='z', z=3, cat=0, separator='comma',
- output=cls.vector_points,
- columns="x double precision, y double precision,"
- " z double precision, return_n integer,"
- " n_returns integer, class_n integer")
- cls.runModule('v.out.lidar',
- input=cls.vector_points, layer=1,
- output=cls.las_file,
- return_column='return_n',
- n_returns_column='n_returns',
- class_column='class_n')
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region and generated data"""
- cls.runModule('g.remove', flags='f', type='vector',
- name=cls.vector_points)
- if os.path.isfile(cls.las_file):
- os.remove(cls.las_file)
- cls.del_temp_region()
-
- def tearDown(self):
- """Remove the outputs created by the import
-
- This is executed after each test run.
- """
- self.runModule('g.remove', flags='f', type='vector',
- name=self.imported_points)
-
- def test_no_filter(self):
- """Test to see if the standard outputs are created
-
- This shows if the inpute data are as expected.
- """
- self.assertModule('v.in.lidar', input=self.las_file,
- output=self.imported_points, flags='bt')
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=19))
-
- def return_filter(self, name, npoints):
- """Mid return filter test"""
- self.assertModule('v.in.lidar', input=self.las_file,
- output=self.imported_points, flags='bt',
- return_filter=name)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=npoints))
-
- def test_first_return_filter(self):
- """First return filter test"""
- self.return_filter('first', 9)
-
- def test_mid_return_filter(self):
- """Mid return filter test"""
- self.return_filter('mid', 5)
-
- def test_last_return_filter(self):
- """Last return filter test"""
- self.return_filter('last', 5)
-
- def class_filter(self, class_n, npoints):
- """Actual code for testing class filter"""
- self.assertModule('v.in.lidar', input=self.las_file,
- output=self.imported_points, flags='bt',
- class_filter=class_n)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=npoints))
-
- def test_class_2_filter(self):
- """Test to filter classes"""
- self.class_filter(2, 2)
-
- def test_class_3_filter(self):
- """Test to filter classes"""
- self.class_filter(3, 5)
-
- def test_class_4_filter(self):
- """Test to filter classes"""
- self.class_filter(4, 4)
-
- def test_class_5_filter(self):
- """Test to filter classes"""
- self.class_filter(5, 8)
-
- def return_and_class_filter(self, return_name, class_n, npoints):
- """Return and class filter combined test code"""
- self.assertModule('v.in.lidar', input=self.las_file,
- output=self.imported_points, flags='bt',
- return_filter=return_name, class_filter=class_n)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=npoints))
-
- def test_first_return_and_class_filter(self):
- """Combined test for return and class"""
- self.return_and_class_filter('first', 2, 2)
-
- def test_last_return_and_class_filter(self):
- """Combined test for return and class"""
- self.return_and_class_filter('last', 5, 3)
-
- def zrange_filter(self, zrange, npoints):
- """Actual code for zrange option test"""
- self.assertModule('v.in.lidar', input=self.las_file,
- output=self.imported_points, flags='bt',
- zrange=zrange)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=npoints))
-
- def test_zrange_filter(self):
- """Test zrange option"""
- self.zrange_filter((130.1, 139.9), 3)
-
- def test_non_int_zrange_filter(self):
- """Test zrange option with float number
-
- One test point has z right under and one other right above the min.
- """
- self.zrange_filter((140.5, 900), 8)
-
- def test_zrange_and_class_filter(self):
- """zrange and class_filter option combined test"""
- self.assertModule('v.in.lidar', input=self.las_file,
- output=self.imported_points, flags='bt',
- zrange=(141, 900), class_filter=5)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=4))
-
- def test_zrange_and_return_filter(self):
- """zrange and class_filter option combined test"""
- self.assertModule('v.in.lidar', input=self.las_file,
- output=self.imported_points, flags='bt',
- zrange=(141, 900), return_filter='last')
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=2))
-
-
-if __name__ == '__main__':
- test()
Copied: grass/trunk/vector/v.in.lidar/testsuite/test_v_in_lidar_basic.py (from rev 74225, grass/trunk/vector/v.in.lidar/testsuite/basic_test.py)
===================================================================
--- grass/trunk/vector/v.in.lidar/testsuite/test_v_in_lidar_basic.py (rev 0)
+++ grass/trunk/vector/v.in.lidar/testsuite/test_v_in_lidar_basic.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,68 @@
+"""
+Name: decimation_test
+Purpose: v.in.lidar decimation test
+
+Author: Vaclav Petras
+Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
+Licence: This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+"""
+
+import os
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+
+class BasicTest(TestCase):
+ """Test case for watershed module
+
+ This tests expects v.random and v.out.lidar to work properly.
+ """
+
+ # Setup variables to be used for outputs
+ vector_points = 'vinlidar_basic_original'
+ imported_points = 'vinlidar_basic_imported'
+ las_file = 'vinlidar_basic_points.las'
+ npoints = 300
+
+ @classmethod
+ def setUpClass(cls):
+ """Ensures expected computational region and generated data"""
+ cls.use_temp_region()
+ cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
+ cls.runModule('v.random', flags='zb', output=cls.vector_points,
+ npoints=cls.npoints, zmin=200, zmax=500, seed=100)
+ cls.runModule('v.out.lidar', input=cls.vector_points,
+ output=cls.las_file)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region and generated data"""
+ cls.runModule('g.remove', flags='f', type='vector',
+ name=cls.vector_points)
+ if os.path.isfile(cls.las_file):
+ os.remove(cls.las_file)
+ cls.del_temp_region()
+
+ def tearDown(self):
+ """Remove the outputs created by the import
+
+ This is executed after each test run.
+ """
+ self.runModule('g.remove', flags='f', type='vector',
+ name=self.imported_points)
+
+ def test_output_identical(self):
+ """Test to see if the standard outputs are created"""
+ self.assertModule('v.in.lidar', input=self.las_file,
+ output=self.imported_points, flags='bt')
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorEqualsVector(
+ actual=self.imported_points,
+ reference=self.vector_points,
+ digits=2, precision=.01)
+
+
+if __name__ == '__main__':
+ test()
Copied: grass/trunk/vector/v.in.lidar/testsuite/test_v_in_lidar_filter.py (from rev 74225, grass/trunk/vector/v.in.lidar/testsuite/filter_test.py)
===================================================================
--- grass/trunk/vector/v.in.lidar/testsuite/test_v_in_lidar_filter.py (rev 0)
+++ grass/trunk/vector/v.in.lidar/testsuite/test_v_in_lidar_filter.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,208 @@
+"""
+Name: decimation_test
+Purpose: v.in.lidar decimation test
+
+Author: Vaclav Petras
+Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
+Licence: This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+"""
+
+import os
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+
+POINTS = """\
+17.46938776,18.67346939,143,1,1,2
+20.93877551,17.44897959,125,1,1,2
+18.89795918,14.18367347,130,1,1,3
+15.91836735,10.67346939,126,1,1,3
+21.26530612,11.04081633,128,1,2,3
+22.24489796,13.89795918,123,2,2,3
+23.79591837,17.12244898,151,1,2,3
+17.2244898,16.34693878,124,2,2,4
+17.14285714,14.10204082,134,1,3,4
+19.87755102,11.81632653,146,2,3,4
+18.48979592,11.48979592,140.6,2,3,4
+21.26530612,15.73469388,147,3,3,5
+21.18367347,19.32653061,138,1,3,5
+23.91836735,18.83673469,144,2,3,5
+23.51020408,13.65306122,143,3,3,5
+23.55102041,11.32653061,123,1,4,5
+18.41009273,14.51618034,140.4,2,4,5
+22.13996161,17.2278263,147,3,4,5
+21.41013052,11.05432488,132,4,4,5
+"""
+
+
+class FilterTest(TestCase):
+ """Test case for filter and selection options
+
+ This tests expects v.random and v.out.lidar to work properly.
+ """
+
+ # Setup variables to be used for outputs
+ vector_points = 'vinlidar_filters_original'
+ imported_points = 'vinlidar_filters_imported'
+ las_file = 'vinlidar_filters_points.las'
+ npoints = 300
+
+ @classmethod
+ def setUpClass(cls):
+ """Ensures expected computational region and generated data"""
+ cls.use_temp_region()
+ cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
+ cls.runModule('v.in.ascii', input='-', stdin_=POINTS,
+ flags='z', z=3, cat=0, separator='comma',
+ output=cls.vector_points,
+ columns="x double precision, y double precision,"
+ " z double precision, return_n integer,"
+ " n_returns integer, class_n integer")
+ cls.runModule('v.out.lidar',
+ input=cls.vector_points, layer=1,
+ output=cls.las_file,
+ return_column='return_n',
+ n_returns_column='n_returns',
+ class_column='class_n')
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region and generated data"""
+ cls.runModule('g.remove', flags='f', type='vector',
+ name=cls.vector_points)
+ if os.path.isfile(cls.las_file):
+ os.remove(cls.las_file)
+ cls.del_temp_region()
+
+ def tearDown(self):
+ """Remove the outputs created by the import
+
+ This is executed after each test run.
+ """
+ self.runModule('g.remove', flags='f', type='vector',
+ name=self.imported_points)
+
+ def test_no_filter(self):
+ """Test to see if the standard outputs are created
+
+ This shows if the inpute data are as expected.
+ """
+ self.assertModule('v.in.lidar', input=self.las_file,
+ output=self.imported_points, flags='bt')
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=19))
+
+ def return_filter(self, name, npoints):
+ """Mid return filter test"""
+ self.assertModule('v.in.lidar', input=self.las_file,
+ output=self.imported_points, flags='bt',
+ return_filter=name)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=npoints))
+
+ def test_first_return_filter(self):
+ """First return filter test"""
+ self.return_filter('first', 9)
+
+ def test_mid_return_filter(self):
+ """Mid return filter test"""
+ self.return_filter('mid', 5)
+
+ def test_last_return_filter(self):
+ """Last return filter test"""
+ self.return_filter('last', 5)
+
+ def class_filter(self, class_n, npoints):
+ """Actual code for testing class filter"""
+ self.assertModule('v.in.lidar', input=self.las_file,
+ output=self.imported_points, flags='bt',
+ class_filter=class_n)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=npoints))
+
+ def test_class_2_filter(self):
+ """Test to filter classes"""
+ self.class_filter(2, 2)
+
+ def test_class_3_filter(self):
+ """Test to filter classes"""
+ self.class_filter(3, 5)
+
+ def test_class_4_filter(self):
+ """Test to filter classes"""
+ self.class_filter(4, 4)
+
+ def test_class_5_filter(self):
+ """Test to filter classes"""
+ self.class_filter(5, 8)
+
+ def return_and_class_filter(self, return_name, class_n, npoints):
+ """Return and class filter combined test code"""
+ self.assertModule('v.in.lidar', input=self.las_file,
+ output=self.imported_points, flags='bt',
+ return_filter=return_name, class_filter=class_n)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=npoints))
+
+ def test_first_return_and_class_filter(self):
+ """Combined test for return and class"""
+ self.return_and_class_filter('first', 2, 2)
+
+ def test_last_return_and_class_filter(self):
+ """Combined test for return and class"""
+ self.return_and_class_filter('last', 5, 3)
+
+ def zrange_filter(self, zrange, npoints):
+ """Actual code for zrange option test"""
+ self.assertModule('v.in.lidar', input=self.las_file,
+ output=self.imported_points, flags='bt',
+ zrange=zrange)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=npoints))
+
+ def test_zrange_filter(self):
+ """Test zrange option"""
+ self.zrange_filter((130.1, 139.9), 3)
+
+ def test_non_int_zrange_filter(self):
+ """Test zrange option with float number
+
+ One test point has z right under and one other right above the min.
+ """
+ self.zrange_filter((140.5, 900), 8)
+
+ def test_zrange_and_class_filter(self):
+ """zrange and class_filter option combined test"""
+ self.assertModule('v.in.lidar', input=self.las_file,
+ output=self.imported_points, flags='bt',
+ zrange=(141, 900), class_filter=5)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=4))
+
+ def test_zrange_and_return_filter(self):
+ """zrange and class_filter option combined test"""
+ self.assertModule('v.in.lidar', input=self.las_file,
+ output=self.imported_points, flags='bt',
+ zrange=(141, 900), return_filter='last')
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=2))
+
+
+if __name__ == '__main__':
+ test()
Copied: grass/trunk/vector/v.in.lidar/testsuite/test_v_in_pdal_basic.py (from rev 74225, grass/trunk/vector/v.in.pdal/testsuite/basic_test.py)
===================================================================
--- grass/trunk/vector/v.in.lidar/testsuite/test_v_in_pdal_basic.py (rev 0)
+++ grass/trunk/vector/v.in.lidar/testsuite/test_v_in_pdal_basic.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,71 @@
+"""
+Name: basic_test
+Purpose: v.in.pdal basic functionality test
+
+Author: Vaclav Petras
+Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
+Licence: This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+"""
+
+import os
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+
+class BasicTest(TestCase):
+ """Test case for watershed module
+
+ This tests expects v.random and v.out.lidar to work properly.
+ """
+
+ # Setup variables to be used for outputs
+ vector_generated = 'vinlidar_basic_generated'
+ vector_points = 'vinlidar_basic_original'
+ imported_points = 'vinlidar_basic_imported'
+ las_file = 'vinlidar_basic_points.las'
+ npoints = 300
+
+ @classmethod
+ def setUpClass(cls):
+ """Ensures expected computational region and generated data"""
+ cls.use_temp_region()
+ cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
+ cls.runModule('v.random', flags='zb', output=cls.vector_generated,
+ npoints=cls.npoints, zmin=200, zmax=500, seed=100)
+ cls.runModule('v.category', input=cls.vector_generated,
+ output=cls.vector_points, option='del', cat=-1)
+ cls.runModule('v.out.lidar', input=cls.vector_points,
+ output=cls.las_file)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region and generated data"""
+ cls.runModule('g.remove', flags='f', type='vector',
+ name=(cls.vector_points, cls.vector_generated))
+ if os.path.isfile(cls.las_file):
+ os.remove(cls.las_file)
+ cls.del_temp_region()
+
+ def tearDown(self):
+ """Remove the outputs created by the import
+
+ This is executed after each test run.
+ """
+ self.runModule('g.remove', flags='f', type='vector',
+ name=self.imported_points)
+
+ def test_same_data(self):
+ """Test to see if the standard outputs are created"""
+ self.assertModule('v.in.pdal', input=self.las_file, flags='c',
+ output=self.imported_points)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorEqualsVector(
+ actual=self.imported_points,
+ reference=self.vector_points,
+ digits=2, precision=.01)
+
+
+if __name__ == '__main__':
+ test()
Copied: grass/trunk/vector/v.in.lidar/testsuite/test_v_in_pdal_filter.py (from rev 74225, grass/trunk/vector/v.in.pdal/testsuite/filter_test.py)
===================================================================
--- grass/trunk/vector/v.in.lidar/testsuite/test_v_in_pdal_filter.py (rev 0)
+++ grass/trunk/vector/v.in.lidar/testsuite/test_v_in_pdal_filter.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -0,0 +1,208 @@
+"""
+Name: filter_test
+Purpose: v.in.pdal test if various filters and selections
+
+Author: Vaclav Petras
+Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
+Licence: This program is free software under the GNU General Public
+ License (>=v2). Read the file COPYING that comes with GRASS
+ for details.
+"""
+
+import os
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+
+POINTS = """\
+17.46938776,18.67346939,143,1,1,2
+20.93877551,17.44897959,125,1,1,2
+18.89795918,14.18367347,130,1,1,3
+15.91836735,10.67346939,126,1,1,3
+21.26530612,11.04081633,128,1,2,3
+22.24489796,13.89795918,123,2,2,3
+23.79591837,17.12244898,151,1,2,3
+17.2244898,16.34693878,124,2,2,4
+17.14285714,14.10204082,134,1,3,4
+19.87755102,11.81632653,146,2,3,4
+18.48979592,11.48979592,140.6,2,3,4
+21.26530612,15.73469388,147,3,3,5
+21.18367347,19.32653061,138,1,3,5
+23.91836735,18.83673469,144,2,3,5
+23.51020408,13.65306122,143,3,3,5
+23.55102041,11.32653061,123,1,4,5
+18.41009273,14.51618034,140.4,2,4,5
+22.13996161,17.2278263,147,3,4,5
+21.41013052,11.05432488,132,4,4,5
+"""
+
+
+class FilterTest(TestCase):
+ """Test case for filter and selection options
+
+ This tests expects v.random and v.out.lidar to work properly.
+ """
+
+ # Setup variables to be used for outputs
+ vector_points = 'vinlidar_filters_original'
+ imported_points = 'vinlidar_filters_imported'
+ las_file = 'vinlidar_filters_points.las'
+ npoints = 300
+
+ @classmethod
+ def setUpClass(cls):
+ """Ensures expected computational region and generated data"""
+ cls.use_temp_region()
+ cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
+ cls.runModule('v.in.ascii', input='-', stdin_=POINTS,
+ flags='z', z=3, cat=0, separator='comma',
+ output=cls.vector_points,
+ columns="x double precision, y double precision,"
+ " z double precision, return_n integer,"
+ " n_returns integer, class_n integer")
+ cls.runModule('v.out.lidar',
+ input=cls.vector_points, layer=1,
+ output=cls.las_file,
+ return_column='return_n',
+ n_returns_column='n_returns',
+ class_column='class_n')
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region and generated data"""
+ cls.runModule('g.remove', flags='f', type='vector',
+ name=cls.vector_points)
+ if os.path.isfile(cls.las_file):
+ os.remove(cls.las_file)
+ cls.del_temp_region()
+
+ def tearDown(self):
+ """Remove the outputs created by the import
+
+ This is executed after each test run.
+ """
+ self.runModule('g.remove', flags='f', type='vector',
+ name=self.imported_points)
+
+ def test_no_filter(self):
+ """Test to see if the standard outputs are created
+
+ This shows if the inpute data are as expected.
+ """
+ self.assertModule('v.in.pdal', input=self.las_file,
+ output=self.imported_points)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=19))
+
+ def return_filter(self, name, npoints):
+ """Mid return filter test"""
+ self.assertModule('v.in.pdal', input=self.las_file,
+ output=self.imported_points,
+ return_filter=name)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=npoints))
+
+ def test_first_return_filter(self):
+ """First return filter test"""
+ self.return_filter('first', 9)
+
+ def test_mid_return_filter(self):
+ """Mid return filter test"""
+ self.return_filter('mid', 5)
+
+ def test_last_return_filter(self):
+ """Last return filter test"""
+ self.return_filter('last', 5)
+
+ def class_filter(self, class_n, npoints):
+ """Actual code for testing class filter"""
+ self.assertModule('v.in.pdal', input=self.las_file,
+ output=self.imported_points,
+ class_filter=class_n)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=npoints))
+
+ def test_class_2_filter(self):
+ """Test to filter classes"""
+ self.class_filter(2, 2)
+
+ def test_class_3_filter(self):
+ """Test to filter classes"""
+ self.class_filter(3, 5)
+
+ def test_class_4_filter(self):
+ """Test to filter classes"""
+ self.class_filter(4, 4)
+
+ def test_class_5_filter(self):
+ """Test to filter classes"""
+ self.class_filter(5, 8)
+
+ def return_and_class_filter(self, return_name, class_n, npoints):
+ """Return and class filter combined test code"""
+ self.assertModule('v.in.pdal', input=self.las_file,
+ output=self.imported_points,
+ return_filter=return_name, class_filter=class_n)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=npoints))
+
+ def test_first_return_and_class_filter(self):
+ """Combined test for return and class"""
+ self.return_and_class_filter('first', 2, 2)
+
+ def test_last_return_and_class_filter(self):
+ """Combined test for return and class"""
+ self.return_and_class_filter('last', 5, 3)
+
+ def zrange_filter(self, zrange, npoints):
+ """Actual code for zrange option test"""
+ self.assertModule('v.in.pdal', input=self.las_file,
+ output=self.imported_points,
+ zrange=zrange)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=npoints))
+
+ def test_zrange_filter(self):
+ """Test zrange option"""
+ self.zrange_filter((130.1, 139.9), 3)
+
+ def test_non_int_zrange_filter(self):
+ """Test zrange option with float number
+
+ One test point has z right under and one other right above the min.
+ """
+ self.zrange_filter((140.5, 900), 8)
+
+ def test_zrange_and_class_filter(self):
+ """zrange and class_filter option combined test"""
+ self.assertModule('v.in.pdal', input=self.las_file,
+ output=self.imported_points,
+ zrange=(141, 900), class_filter=5)
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=4))
+
+ def test_zrange_and_return_filter(self):
+ """zrange and class_filter option combined test"""
+ self.assertModule('v.in.pdal', input=self.las_file,
+ output=self.imported_points,
+ zrange=(141, 900), return_filter='last')
+ self.assertVectorExists(self.imported_points)
+ self.assertVectorFitsTopoInfo(
+ vector=self.imported_points,
+ reference=dict(points=2))
+
+
+if __name__ == '__main__':
+ test()
Deleted: grass/trunk/vector/v.in.pdal/testsuite/basic_test.py
===================================================================
--- grass/trunk/vector/v.in.pdal/testsuite/basic_test.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/vector/v.in.pdal/testsuite/basic_test.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,71 +0,0 @@
-"""
-Name: basic_test
-Purpose: v.in.pdal basic functionality test
-
-Author: Vaclav Petras
-Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
-Licence: This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-"""
-
-import os
-from grass.gunittest.case import TestCase
-from grass.gunittest.main import test
-
-
-class BasicTest(TestCase):
- """Test case for watershed module
-
- This tests expects v.random and v.out.lidar to work properly.
- """
-
- # Setup variables to be used for outputs
- vector_generated = 'vinlidar_basic_generated'
- vector_points = 'vinlidar_basic_original'
- imported_points = 'vinlidar_basic_imported'
- las_file = 'vinlidar_basic_points.las'
- npoints = 300
-
- @classmethod
- def setUpClass(cls):
- """Ensures expected computational region and generated data"""
- cls.use_temp_region()
- cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
- cls.runModule('v.random', flags='zb', output=cls.vector_generated,
- npoints=cls.npoints, zmin=200, zmax=500, seed=100)
- cls.runModule('v.category', input=cls.vector_generated,
- output=cls.vector_points, option='del', cat=-1)
- cls.runModule('v.out.lidar', input=cls.vector_points,
- output=cls.las_file)
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region and generated data"""
- cls.runModule('g.remove', flags='f', type='vector',
- name=(cls.vector_points, cls.vector_generated))
- if os.path.isfile(cls.las_file):
- os.remove(cls.las_file)
- cls.del_temp_region()
-
- def tearDown(self):
- """Remove the outputs created by the import
-
- This is executed after each test run.
- """
- self.runModule('g.remove', flags='f', type='vector',
- name=self.imported_points)
-
- def test_same_data(self):
- """Test to see if the standard outputs are created"""
- self.assertModule('v.in.pdal', input=self.las_file, flags='c',
- output=self.imported_points)
- self.assertVectorExists(self.imported_points)
- self.assertVectorEqualsVector(
- actual=self.imported_points,
- reference=self.vector_points,
- digits=2, precision=.01)
-
-
-if __name__ == '__main__':
- test()
Deleted: grass/trunk/vector/v.in.pdal/testsuite/filter_test.py
===================================================================
--- grass/trunk/vector/v.in.pdal/testsuite/filter_test.py 2019-03-12 21:48:48 UTC (rev 74225)
+++ grass/trunk/vector/v.in.pdal/testsuite/filter_test.py 2019-03-12 22:22:35 UTC (rev 74226)
@@ -1,208 +0,0 @@
-"""
-Name: filter_test
-Purpose: v.in.pdal test if various filters and selections
-
-Author: Vaclav Petras
-Copyright: (C) 2015 by Vaclav Petras and the GRASS Development Team
-Licence: This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-"""
-
-import os
-from grass.gunittest.case import TestCase
-from grass.gunittest.main import test
-
-
-POINTS = """\
-17.46938776,18.67346939,143,1,1,2
-20.93877551,17.44897959,125,1,1,2
-18.89795918,14.18367347,130,1,1,3
-15.91836735,10.67346939,126,1,1,3
-21.26530612,11.04081633,128,1,2,3
-22.24489796,13.89795918,123,2,2,3
-23.79591837,17.12244898,151,1,2,3
-17.2244898,16.34693878,124,2,2,4
-17.14285714,14.10204082,134,1,3,4
-19.87755102,11.81632653,146,2,3,4
-18.48979592,11.48979592,140.6,2,3,4
-21.26530612,15.73469388,147,3,3,5
-21.18367347,19.32653061,138,1,3,5
-23.91836735,18.83673469,144,2,3,5
-23.51020408,13.65306122,143,3,3,5
-23.55102041,11.32653061,123,1,4,5
-18.41009273,14.51618034,140.4,2,4,5
-22.13996161,17.2278263,147,3,4,5
-21.41013052,11.05432488,132,4,4,5
-"""
-
-
-class FilterTest(TestCase):
- """Test case for filter and selection options
-
- This tests expects v.random and v.out.lidar to work properly.
- """
-
- # Setup variables to be used for outputs
- vector_points = 'vinlidar_filters_original'
- imported_points = 'vinlidar_filters_imported'
- las_file = 'vinlidar_filters_points.las'
- npoints = 300
-
- @classmethod
- def setUpClass(cls):
- """Ensures expected computational region and generated data"""
- cls.use_temp_region()
- cls.runModule('g.region', n=20, s=10, e=25, w=15, res=1)
- cls.runModule('v.in.ascii', input='-', stdin_=POINTS,
- flags='z', z=3, cat=0, separator='comma',
- output=cls.vector_points,
- columns="x double precision, y double precision,"
- " z double precision, return_n integer,"
- " n_returns integer, class_n integer")
- cls.runModule('v.out.lidar',
- input=cls.vector_points, layer=1,
- output=cls.las_file,
- return_column='return_n',
- n_returns_column='n_returns',
- class_column='class_n')
-
- @classmethod
- def tearDownClass(cls):
- """Remove the temporary region and generated data"""
- cls.runModule('g.remove', flags='f', type='vector',
- name=cls.vector_points)
- if os.path.isfile(cls.las_file):
- os.remove(cls.las_file)
- cls.del_temp_region()
-
- def tearDown(self):
- """Remove the outputs created by the import
-
- This is executed after each test run.
- """
- self.runModule('g.remove', flags='f', type='vector',
- name=self.imported_points)
-
- def test_no_filter(self):
- """Test to see if the standard outputs are created
-
- This shows if the inpute data are as expected.
- """
- self.assertModule('v.in.pdal', input=self.las_file,
- output=self.imported_points)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=19))
-
- def return_filter(self, name, npoints):
- """Mid return filter test"""
- self.assertModule('v.in.pdal', input=self.las_file,
- output=self.imported_points,
- return_filter=name)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=npoints))
-
- def test_first_return_filter(self):
- """First return filter test"""
- self.return_filter('first', 9)
-
- def test_mid_return_filter(self):
- """Mid return filter test"""
- self.return_filter('mid', 5)
-
- def test_last_return_filter(self):
- """Last return filter test"""
- self.return_filter('last', 5)
-
- def class_filter(self, class_n, npoints):
- """Actual code for testing class filter"""
- self.assertModule('v.in.pdal', input=self.las_file,
- output=self.imported_points,
- class_filter=class_n)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=npoints))
-
- def test_class_2_filter(self):
- """Test to filter classes"""
- self.class_filter(2, 2)
-
- def test_class_3_filter(self):
- """Test to filter classes"""
- self.class_filter(3, 5)
-
- def test_class_4_filter(self):
- """Test to filter classes"""
- self.class_filter(4, 4)
-
- def test_class_5_filter(self):
- """Test to filter classes"""
- self.class_filter(5, 8)
-
- def return_and_class_filter(self, return_name, class_n, npoints):
- """Return and class filter combined test code"""
- self.assertModule('v.in.pdal', input=self.las_file,
- output=self.imported_points,
- return_filter=return_name, class_filter=class_n)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=npoints))
-
- def test_first_return_and_class_filter(self):
- """Combined test for return and class"""
- self.return_and_class_filter('first', 2, 2)
-
- def test_last_return_and_class_filter(self):
- """Combined test for return and class"""
- self.return_and_class_filter('last', 5, 3)
-
- def zrange_filter(self, zrange, npoints):
- """Actual code for zrange option test"""
- self.assertModule('v.in.pdal', input=self.las_file,
- output=self.imported_points,
- zrange=zrange)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=npoints))
-
- def test_zrange_filter(self):
- """Test zrange option"""
- self.zrange_filter((130.1, 139.9), 3)
-
- def test_non_int_zrange_filter(self):
- """Test zrange option with float number
-
- One test point has z right under and one other right above the min.
- """
- self.zrange_filter((140.5, 900), 8)
-
- def test_zrange_and_class_filter(self):
- """zrange and class_filter option combined test"""
- self.assertModule('v.in.pdal', input=self.las_file,
- output=self.imported_points,
- zrange=(141, 900), class_filter=5)
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=4))
-
- def test_zrange_and_return_filter(self):
- """zrange and class_filter option combined test"""
- self.assertModule('v.in.pdal', input=self.las_file,
- output=self.imported_points,
- zrange=(141, 900), return_filter='last')
- self.assertVectorExists(self.imported_points)
- self.assertVectorFitsTopoInfo(
- vector=self.imported_points,
- reference=dict(points=2))
-
-
-if __name__ == '__main__':
- test()
More information about the grass-commit
mailing list