[GRASS-SVN] r71628 - in grass-addons/grass7/raster/r.geomorphon: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Nov 2 08:55:55 PDT 2017


Author: lucadelu
Date: 2017-11-02 08:55:55 -0700 (Thu, 02 Nov 2017)
New Revision: 71628

Added:
   grass-addons/grass7/raster/r.geomorphon/testsuite/
   grass-addons/grass7/raster/r.geomorphon/testsuite/test_r_geom.py
Log:
r.geomorphon: added tests

Added: grass-addons/grass7/raster/r.geomorphon/testsuite/test_r_geom.py
===================================================================
--- grass-addons/grass7/raster/r.geomorphon/testsuite/test_r_geom.py	                        (rev 0)
+++ grass-addons/grass7/raster/r.geomorphon/testsuite/test_r_geom.py	2017-11-02 15:55:55 UTC (rev 71628)
@@ -0,0 +1,72 @@
+"""
+Name:       r.geomorphon tests
+Purpose:    Tests r.geomorphon input parsing.
+            Uses NC Basic data set.
+
+Author:     Luca Delucchi, Markus Neteler
+Copyright:  (C) 2017 by Luca Delucchi, Markus Neteler 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.
+"""
+
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+from grass.script.core import read_command
+
+synth_out = \
+"""1	flat
+3	ridge
+4	shoulder
+6	slope
+8	footslope
+9	valley
+"""
+
+ele_out = \
+"""1	flat
+2	summit
+3	ridge
+4	shoulder
+5	spur
+6	slope
+7	hollow
+8	footslope
+9	valley
+10	depression
+"""
+
+class TestClipling(TestCase):
+    inele = 'elevation'
+    insint = 'synthetic_dem'
+    outele = 'ele_geomorph'
+    outsint = 'synth_geomorph'
+
+    @classmethod
+    def setUpClass(cls):
+        """Ensures expected computational region and generated data"""
+        cls.use_temp_region()
+        cls.runModule('g.region', raster=cls.inele)
+        cls.runModule('r.mapcalc', expression="{ou} = sin(x() / 5.0) + (sin(x() / 5.0) * 100.0 + 200)".format(ou=cls.insint))
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region and generated data"""
+        cls.runModule('g.remove', flags='f', type='raster',
+                      name=(cls.insint, cls.outele, cls.outsint))
+        cls.del_temp_region()
+    
+    def test_ele(self):
+        self.runModule('r.geomorphon', elevation=self.inele, forms=self.outele,
+                      search=10)
+        category = read_command('r.category', map=self.outele)
+        self.assertEqual(first=ele_out, second=category)
+
+    def test_sint(self):
+        self.runModule('r.geomorphon', elevation=self.insint,
+                       forms=self.outsint, search=10)
+        category = read_command('r.category', map=self.outsint)
+        self.assertEqual(first=synth_out, second=category)
+    
+if __name__ == '__main__':
+    test()


Property changes on: grass-addons/grass7/raster/r.geomorphon/testsuite/test_r_geom.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list