[GRASS-SVN] r61239 - in grass/trunk/raster/r.series.interp: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jul 12 03:38:53 PDT 2014
Author: huhabla
Date: 2014-07-12 03:38:53 -0700 (Sat, 12 Jul 2014)
New Revision: 61239
Added:
grass/trunk/raster/r.series.interp/testsuite/
grass/trunk/raster/r.series.interp/testsuite/infile_2.txt
grass/trunk/raster/r.series.interp/testsuite/interp_test.py
grass/trunk/raster/r.series.interp/testsuite/outfile_1.txt
grass/trunk/raster/r.series.interp/testsuite/outfile_2.txt
grass/trunk/raster/r.series.interp/testsuite/outfile_corrupt.txt
Modified:
grass/trunk/raster/r.series.interp/main.c
Log:
Converted shell test script into Python using the gunittest framework.
Fixed command line description.
Modified: grass/trunk/raster/r.series.interp/main.c
===================================================================
--- grass/trunk/raster/r.series.interp/main.c 2014-07-11 17:24:37 UTC (rev 61238)
+++ grass/trunk/raster/r.series.interp/main.c 2014-07-12 10:38:53 UTC (rev 61239)
@@ -80,7 +80,7 @@
parm.infile = G_define_standard_option(G_OPT_F_INPUT);
parm.infile->key = "infile";
- parm.infile->description = _("Input file with an input raster map name and data point position per line,"
+ parm.infile->description = _("Input file with one input raster map name and data point position per line,"
" field separator between name and sample point is |");
parm.infile->required = NO;
@@ -97,7 +97,7 @@
parm.outfile = G_define_standard_option(G_OPT_F_INPUT);
parm.outfile->key = "outfile";
- parm.outfile->description = _("Input infile with an output raster map name and sample point position per line,"
+ parm.outfile->description = _("Input file with one output raster map name and sample point position per line,"
" field separator between name and sample point is |");
parm.outfile->required = NO;
Added: grass/trunk/raster/r.series.interp/testsuite/infile_2.txt
===================================================================
--- grass/trunk/raster/r.series.interp/testsuite/infile_2.txt (rev 0)
+++ grass/trunk/raster/r.series.interp/testsuite/infile_2.txt 2014-07-12 10:38:53 UTC (rev 61239)
@@ -0,0 +1,4 @@
+map_10|10
+map_20|20
+map_30|30
+map_40|40
Added: grass/trunk/raster/r.series.interp/testsuite/interp_test.py
===================================================================
--- grass/trunk/raster/r.series.interp/testsuite/interp_test.py (rev 0)
+++ grass/trunk/raster/r.series.interp/testsuite/interp_test.py 2014-07-12 10:38:53 UTC (rev 61239)
@@ -0,0 +1,93 @@
+"""Test to verify r.gwflow calculation, this calculation is based on
+the example at page 133 of the following book:
+author = "Kinzelbach, W. and Rausch, R.",
+title = "Grundwassermodellierung",
+publisher = "Gebr{\"u}der Borntraeger (Berlin, Stuttgart)",
+year = "1995"
+
+ at author Soeren Gebbert
+"""
+from grass.gunittest.case import TestCase
+
+class Validation7x7Grid(TestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ """Use temporary region settings"""
+ cls.use_temp_region()
+ cls.runModule("g.region", res=10, n=80, s=0, w=0, e=120)
+ cls.runModule("g.gisenv", set="OVERWRITE=1")
+
+ @classmethod
+ def tearDownClass(cls):
+ """!Remove the temporary region
+ """
+ cls.del_temp_region()
+
+ def setUp(self):
+ """Generate interpolation data
+ """
+ self.runModule("r.mapcalc", expression="prec_1 = 100")
+ self.runModule("r.mapcalc", expression="prec_5 = 500")
+ self.runModule("r.mapcalc", expression="map_10 = 10")
+ self.runModule("r.mapcalc", expression="map_20 = 20")
+ self.runModule("r.mapcalc", expression="map_30 = 30")
+ self.runModule("r.mapcalc", expression="map_40 = 40")
+
+ def test_commandline(self):
+ self.assertModule("r.series.interp", input="prec_1,prec_5", datapos=(0.0,1.0),
+ output="prec_2,prec_3,prec_4", samplingpos=(0.25,0.5,0.75), method="linear")
+
+ self.assertRasterMinMax(map="prec_2", refmin=200, refmax=200)
+ self.assertRasterMinMax(map="prec_3", refmin=300, refmax=300)
+ self.assertRasterMinMax(map="prec_4", refmin=400, refmax=400)
+
+ def test_infile(self):
+ self.assertModule("r.series.interp", input="prec_1,prec_5", datapos=(0.0,1.0),
+ outfile="outfile_1.txt", method="linear")
+
+ self.assertRasterMinMax(map="prec_2", refmin=200, refmax=200)
+ self.assertRasterMinMax(map="prec_3", refmin=300, refmax=300)
+ self.assertRasterMinMax(map="prec_4", refmin=400, refmax=400)
+
+ def test_inoutfiles(self):
+ self.assertModule("r.series.interp", infile="infile_2.txt",
+ outfile="outfile_2.txt", method="linear")
+
+ self.assertRasterMinMax(map="map_12", refmin=12, refmax=12)
+ self.assertRasterMinMax(map="map_14", refmin=14, refmax=14)
+ self.assertRasterMinMax(map="map_16", refmin=16, refmax=16)
+ self.assertRasterMinMax(map="map_18", refmin=18, refmax=18)
+ self.assertRasterMinMax(map="map_25", refmin=25, refmax=25)
+ self.assertRasterMinMax(map="map_35", refmin=35, refmax=35)
+
+
+ def test_module_failure(self):
+ """ We need tests to check the failure handling, as outputs, file and
+ sampling points are not handled by the grass parser"""
+
+ # No outputs
+ self.assertModuleFail("r.series.interp", input="prec_1,prec_5", datapos=(0.0,1.0),
+ samplingpos=(0.25,0.5,0.75), method="linear")
+ # No sampling points
+ self.assertModuleFail("r.series.interp", input="prec_1,prec_5",
+ datapos=(0.0,1.0), output="prec_2,prec_3,prec_4")
+ # Output and file at once
+ self.assertModuleFail("r.series.interp", input="prec_1,prec_5", datapos=(0.0,1.0),
+ outfile="outfile_1.txt", output="prec_2,prec_3,prec_4", samplingpos=(0.25,0.5,0.75),
+ method="linear")
+ # Sampling points and file at once
+ self.assertModuleFail("r.series.interp", input="prec_1,prec_5", datapos=(0.0,1.0),
+ outfile="outfile_1.txt", samplingpos=(0.25,0.5,0.75), method="linear")
+ # Wrong input file
+ self.assertModuleFail("r.series.interp", input="prec_1,prec_5", datapos=(0.0,1.0),
+ outfile="mo_such_file", method="linear")
+ # Wrong input file
+ self.assertModuleFail("r.series.interp", input="prec_1,prec_5", datapos=(0.0,1.0),
+ outfile="outfile_corrupt.txt", method="linear")
+
+if __name__ == '__main__':
+ from grass.gunittest.main import test
+ test()
+
+
Added: grass/trunk/raster/r.series.interp/testsuite/outfile_1.txt
===================================================================
--- grass/trunk/raster/r.series.interp/testsuite/outfile_1.txt (rev 0)
+++ grass/trunk/raster/r.series.interp/testsuite/outfile_1.txt 2014-07-12 10:38:53 UTC (rev 61239)
@@ -0,0 +1,9 @@
+
+prec_2|0.25
+
+
+prec_3|0.5
+
+prec_4|0.75
+
+
Added: grass/trunk/raster/r.series.interp/testsuite/outfile_2.txt
===================================================================
--- grass/trunk/raster/r.series.interp/testsuite/outfile_2.txt (rev 0)
+++ grass/trunk/raster/r.series.interp/testsuite/outfile_2.txt 2014-07-12 10:38:53 UTC (rev 61239)
@@ -0,0 +1,6 @@
+map_12|12
+map_14|14
+map_16|16
+map_18|18
+map_25|25
+map_35|35
Added: grass/trunk/raster/r.series.interp/testsuite/outfile_corrupt.txt
===================================================================
--- grass/trunk/raster/r.series.interp/testsuite/outfile_corrupt.txt (rev 0)
+++ grass/trunk/raster/r.series.interp/testsuite/outfile_corrupt.txt 2014-07-12 10:38:53 UTC (rev 61239)
@@ -0,0 +1,3 @@
+prec_2|0.25
+prec_3|0.5
+prec_4
More information about the grass-commit
mailing list