瀏覽代碼

r.grow: added test, thanks to Sanjeet Bhatti

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74246 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 6 年之前
父節點
當前提交
68161e10fa
共有 1 個文件被更改,包括 49 次插入0 次删除
  1. 49 0
      scripts/r.grow/testsuite/test_r_grow.py

+ 49 - 0
scripts/r.grow/testsuite/test_r_grow.py

@@ -0,0 +1,49 @@
+"""
+Created on Sun Jun 07 22:09:41 2018
+
+@author: Sanjeet Bhatti
+"""
+
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+from grass.gunittest.gmodules import SimpleModule
+from grass.script.core import run_command
+
+
+class TestRGrow(TestCase):
+    """Test r.grow script"""
+
+    mapName = 'lakes'
+    mapGrownOutput = 'lakes_grown_100m'
+    mapShrunkOutput = 'lakes_shrunk_100m'
+
+    @classmethod
+    def setUpClass(cls):
+        """Create maps in a small region."""
+        cls.use_temp_region()
+        cls.runModule('g.region', raster=cls.mapName, flags='p')
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove temporary region"""
+        cls.runModule('g.remove', flags='f', type='raster',
+                      name=(cls.mapGrownOutput,
+                            cls.mapShrunkOutput))
+        cls.del_temp_region()
+
+    def test_grow(self):
+        """Grow test"""
+        module = SimpleModule('r.grow', input=self.mapName,
+                              output=self.mapGrownOutput,
+                              radius=10)
+        self.assertModule(module)
+
+    def test_shrink(self):
+        """Shrink test"""
+        module = SimpleModule('r.grow', input=self.mapName,
+                              output=self.mapShrunkOutput,
+                              radius=-10)
+        self.assertModule(module)
+
+if __name__ == '__main__':
+    test()