[GRASS-SVN] r61429 - grass/trunk/temporal/t.rast.extract/testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jul 28 09:54:23 PDT 2014
Author: huhabla
Date: 2014-07-28 09:54:22 -0700 (Mon, 28 Jul 2014)
New Revision: 61429
Modified:
grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py
Log:
Added error handling tests. Using SimpleModule() for t.info runs.
Modified: grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py
===================================================================
--- grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py 2014-07-28 15:57:23 UTC (rev 61428)
+++ grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py 2014-07-28 16:54:22 UTC (rev 61429)
@@ -8,10 +8,10 @@
@author Soeren Gebbert
"""
-import grass.script as grass
import grass.pygrass.modules as pymod
import subprocess
from grass.gunittest.case import TestCase
+from grass.gunittest.gmodules import SimpleModule
class TestRasterExtraction(TestCase):
@@ -19,7 +19,7 @@
def setUpClass(cls):
"""!Initiate the temporal GIS and set the region
"""
- grass.use_temp_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)
@@ -27,7 +27,7 @@
def tearDownClass(cls):
"""!Remove the temporary region
"""
- grass.del_temp_region()
+ cls.del_temp_region()
def setUp(self):
"""Create input data for transient groundwater flow computation
@@ -79,9 +79,8 @@
max_min=300.0
max_max=600.0"""
- self.assertModuleKeyValue(module="t.info",
- parameters=dict(flags="g", input="precip_abs2"),
- reference=tinfo_string, precision=2, sep="=")
+ 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"""
@@ -113,9 +112,8 @@
max_min=500.0
max_max=600.0"""
- self.assertModuleKeyValue(module="t.info",
- parameters=dict(flags="g", input="precip_abs2"),
- reference=tinfo_string, precision=2, sep="=")
+ 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"""
@@ -146,10 +144,35 @@
max_min=500.0
max_max=600.0"""
- self.assertModuleKeyValue(module="t.info",
- parameters=dict(flags="g", input="precip_abs2"),
- reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule("t.info", flags="g", input="precip_abs2")
+ self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+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()
More information about the grass-commit
mailing list