test_r_grow.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. """
  2. Created on Sun Jun 07 22:09:41 2018
  3. @author: Sanjeet Bhatti
  4. """
  5. from grass.gunittest.case import TestCase
  6. from grass.gunittest.main import test
  7. from grass.gunittest.gmodules import SimpleModule
  8. from grass.script.core import run_command
  9. class TestRGrow(TestCase):
  10. """Test r.grow script"""
  11. mapName = 'lakes'
  12. mapGrownOutput = 'lakes_grown_100m'
  13. mapShrunkOutput = 'lakes_shrunk_100m'
  14. @classmethod
  15. def setUpClass(cls):
  16. """Create maps in a small region."""
  17. cls.use_temp_region()
  18. cls.runModule('g.region', raster=cls.mapName, flags='p')
  19. @classmethod
  20. def tearDownClass(cls):
  21. """Remove temporary region"""
  22. cls.runModule('g.remove', flags='f', type='raster',
  23. name=(cls.mapGrownOutput,
  24. cls.mapShrunkOutput))
  25. cls.del_temp_region()
  26. def test_grow(self):
  27. """Grow test"""
  28. module = SimpleModule('r.grow', input=self.mapName,
  29. output=self.mapGrownOutput,
  30. radius=10)
  31. self.assertModule(module)
  32. def test_shrink(self):
  33. """Shrink test"""
  34. module = SimpleModule('r.grow', input=self.mapName,
  35. output=self.mapShrunkOutput,
  36. radius=-10)
  37. self.assertModule(module)
  38. if __name__ == '__main__':
  39. test()