[GRASS-SVN] r74250 - in grass/trunk/scripts/r.reclass.area: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 13 11:59:29 PDT 2019


Author: lucadelu
Date: 2019-03-13 11:59:29 -0700 (Wed, 13 Mar 2019)
New Revision: 74250

Added:
   grass/trunk/scripts/r.reclass.area/testsuite/
   grass/trunk/scripts/r.reclass.area/testsuite/test_r_reclass_area.py
   grass/trunk/scripts/r.reclass.area/testsuite/testrra.py
Log:
r.reclass.area: added tests from GCI 2018

Added: grass/trunk/scripts/r.reclass.area/testsuite/test_r_reclass_area.py
===================================================================
--- grass/trunk/scripts/r.reclass.area/testsuite/test_r_reclass_area.py	                        (rev 0)
+++ grass/trunk/scripts/r.reclass.area/testsuite/test_r_reclass_area.py	2019-03-13 18:59:29 UTC (rev 74250)
@@ -0,0 +1,47 @@
+"""
+Name:        r.reclass.area  test
+Purpose:    Tests  r.reclass.area.
+
+Author:     Shubham Sharma, Google Code-in 2018
+Copyright:  (C) 2018 by Shubham Sharma 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
+
+
+class TestReclassArea(TestCase):
+    input = 'geology_30m'
+    output = 'reclassarea'
+    value = '20'
+
+    @classmethod
+    def setUpClass(cls):
+        cls.use_temp_region()
+        cls.runModule('g.region', raster=cls.input)
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.del_temp_region()
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output + 'Greater')
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output + 'Lesser')
+
+    def test_reclassaeaGreater(self):
+        """Testing r.reclass.area with greater"""
+        self.assertModule('r.reclass.area', input=self.input, output=self.output + 'Greater',
+                          value=self.value, mode='greater', method='reclass')
+        self.assertRasterMinMax(map=self.output + 'Greater', refmin=200, refmax=1000,
+                                msg="Range of data: min = 200  max = 1000")
+
+    def test_reclassareaLesser(self):
+        """Testing r.reclass.area with lesser"""
+        self.assertModule('r.reclass.area', input=self.input, output=self.output + 'Lesser',
+                          value=self.value, mode='lesser', method='reclass')
+        self.assertRasterMinMax(map=self.output + 'Lesser', refmin=900, refmax=1000,
+                                msg="Range of data: min = 900  max = 1000")
+
+if __name__ == '__main__':
+    test()


Property changes on: grass/trunk/scripts/r.reclass.area/testsuite/test_r_reclass_area.py
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-python
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: grass/trunk/scripts/r.reclass.area/testsuite/testrra.py
===================================================================
--- grass/trunk/scripts/r.reclass.area/testsuite/testrra.py	                        (rev 0)
+++ grass/trunk/scripts/r.reclass.area/testsuite/testrra.py	2019-03-13 18:59:29 UTC (rev 74250)
@@ -0,0 +1,60 @@
+"""
+Name:       r.reclass.area test
+Purpose:    Tests r.reclass.area and its flags/options.
+	
+Author:     Sunveer Singh, Google Code-in 2018
+Copyright:  (C) 2018 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.
+"""
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+class Testrr(TestCase):
+    input='zipcodes'
+    output='rraoutput'
+
+    @classmethod
+    def setUpClass(cls):
+        cls.use_temp_region()
+        cls.runModule('g.region', raster=cls.input)
+	
+    @classmethod
+    def tearDownClass(cls):
+        cls.del_temp_region()
+
+    def tearDown(cls):
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output)
+
+    def test_flag_c(self):
+        """Testing flag c"""
+        string="""min=27603
+        max=27607
+        cells=2025000"""
+        self.assertModule('r.reclass.area', input=self.input, output=self.output, value=2000, mode="greater", flags='c')
+        self.assertRasterFitsUnivar(self.output,
+	                            reference=string, precision=2)
+
+    def test_flag_d(self):
+        """Testing flag d"""
+        self.assertModule('r.reclass.area', input=self.input, output=self.output, value=2000, mode="lesser", flags='d')
+        self.assertRasterMinMax(map=self.output, refmin=27511, refmax=27610,
+	                        msg="Output Map in degrees must be between 27511 and 27610")
+  
+    def test_module_output(self):
+        """Testing Module without flags"""
+        self.assertModule('r.reclass.area', input=self.input, output=self.output, value=2000, mode="greater")
+        self.assertRasterMinMax(map=self.output, refmin=27603, refmax=27607,
+	                        msg="Output Map in degrees must be between 27603 and 27607")    
+
+    def test_method_rmarea(self):
+        """Testing Module without flags"""
+        self.assertModule('r.reclass.area', input=self.input, output=self.output, value=2000, mode="lesser", method="rmarea")
+        self.assertRasterMinMax(map=self.output, refmin=27603, refmax=27607,
+	                        msg="Output Map in degrees must be between 27603 and 27607")
+  
+
+if __name__ == '__main__':
+    from grass.gunittest.main import test
+    test()


Property changes on: grass/trunk/scripts/r.reclass.area/testsuite/testrra.py
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-python
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property


More information about the grass-commit mailing list