[GRASS-SVN] r74230 - in grass/trunk/raster/r.tile: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 13 00:13:23 PDT 2019


Author: lucadelu
Date: 2019-03-13 00:13:23 -0700 (Wed, 13 Mar 2019)
New Revision: 74230

Added:
   grass/trunk/raster/r.tile/testsuite/
   grass/trunk/raster/r.tile/testsuite/test_r_tile.py
   grass/trunk/raster/r.tile/testsuite/testrt.py
Log:
r.tile: added tests from GCI 2018

Added: grass/trunk/raster/r.tile/testsuite/test_r_tile.py
===================================================================
--- grass/trunk/raster/r.tile/testsuite/test_r_tile.py	                        (rev 0)
+++ grass/trunk/raster/r.tile/testsuite/test_r_tile.py	2019-03-13 07:13:23 UTC (rev 74230)
@@ -0,0 +1,65 @@
+"""
+Name:        r.tile test
+Purpose:    Tests r.tile module and the number of created tiles.
+
+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 TestRasterTile(TestCase):
+    input = 'lakes'
+    output_prefix = 'lakes_tile'
+    width = '1000'
+    height = '1000'
+    overlap = '10'
+
+    @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_prefix + '-000-000')
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output_prefix + '-000-001')
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output_prefix + '-001-000')
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output_prefix + '-001-001')
+
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output_prefix + 'overlap' + '-000-000')
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output_prefix + 'overlap' + '-000-001')
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output_prefix + 'overlap' + '-001-000')
+        cls.runModule('g.remove', type='raster', flags='f', name=cls.output_prefix + 'overlap' + '-001-001')
+
+    def test_raster_tile(self):
+        """Testing r.tile runs successfully"""
+        self.assertModule('r.tile', input=self.input, output=self.output_prefix, width=self.width, height=self.height)
+        # If the above statement executed successful then
+        # 4 rasters tiles with following details should exits
+        self.assertRasterExists(self.output_prefix+'-000-000', msg="lakes_tile-000-000 does not exits")
+        self.assertRasterExists(self.output_prefix+'-000-001', msg="lakes_tile-000-001 does not exits")
+        self.assertRasterExists(self.output_prefix+'-001-000', msg="lakes_tile-001-000 does not exits")
+        self.assertRasterExists(self.output_prefix+'-001-001', msg="lakes_tile-001-001 does not exits")
+
+    def test_raster_tile_overlap(self):
+        """Testing r.tile runs successfully with overlap option"""
+        self.assertModule('r.tile', input=self.input, output=self.output_prefix+'overlap', width=self.width, height=self.height, overlap=self.overlap)
+        # If the above statement executed successful then
+        # 4 rasters tiles with following details should exits
+        self.assertRasterExists(self.output_prefix+'overlap'+'-000-000', msg="lakes_tile-000-000 does not exits")
+        self.assertRasterExists(self.output_prefix+'overlap'+'-000-001', msg="lakes_tile-000-001 does not exits")
+        self.assertRasterExists(self.output_prefix+'overlap'+'-001-000', msg="lakes_tile-001-000 does not exits")
+        self.assertRasterExists(self.output_prefix+'overlap'+'-001-001', msg="lakes_tile-001-001 does not exits")
+
+
+
+
+if __name__ == '__main__':
+    test()

Added: grass/trunk/raster/r.tile/testsuite/testrt.py
===================================================================
--- grass/trunk/raster/r.tile/testsuite/testrt.py	                        (rev 0)
+++ grass/trunk/raster/r.tile/testsuite/testrt.py	2019-03-13 07:13:23 UTC (rev 74230)
@@ -0,0 +1,58 @@
+"""
+Name:       r.tile test
+Purpose:    Tests r.tile 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='elevation'
+    output='tile'
+
+    @classmethod
+    def setUpClass(cls):
+        cls.use_temp_region()
+        cls.runModule('g.region', raster=cls.input)
+	
+    @classmethod
+    def tearDownClass(cls):
+        cls.del_temp_region()
+
+
+    def test_basic(self):
+        """Running a basic test"""
+        self.assertModule('r.tile', input=self.input, output=self.output, width=1500/2, height=1350/2)
+
+    def test_univar(self):
+        """Testing the output map tile-001-002"""
+        string="""min=55.5787925720215
+        n=506250
+        max=144.267288208008"""
+        self.assertModule('r.tile', input=self.input, output=self.output, width=1500/2, height=1350/2)
+        self.assertRasterFitsUnivar('tile-000-001',
+	                            reference=string, precision=2)
+
+    def test_overlap(self):
+        """Testing overlap parameter with output map tile-000-000"""
+        tile="tile-000-000"
+        self.assertModule('r.tile', input=self.input, output=self.output, width=1500/2, height=1350/2, overlap=250)
+        self.assertRasterMinMax(map=tile, refmin=74.75374, refmax=156.3299,
+	                        msg="tile-000-000 in degrees must be between 74.75374 and 156.3299") 
+
+    def test_minmax(self):
+        """Testing output map tile-000-001"""
+        tile1="tile-000-001"
+        self.assertModule('r.tile', input=self.input, output=self.output, width=1500/2, height=1350/2)
+        self.assertRasterMinMax(map=tile1, refmin=55.57879, refmax=144.2673,
+	                        msg="tile-000-001 in degrees must be between 55.57879 and 144.2673")
+
+if __name__ == '__main__':
+    from grass.gunittest.main import test
+    test()
+



More information about the grass-commit mailing list