Prechádzať zdrojové kódy

r.reclass.area: added tests from GCI 2018

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74250 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 6 rokov pred
rodič
commit
e0de5944c0

+ 47 - 0
scripts/r.reclass.area/testsuite/test_r_reclass_area.py

@@ -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()

+ 60 - 0
scripts/r.reclass.area/testsuite/testrra.py

@@ -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()