test_r_blend.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """
  2. Created on Sun Jun 07 21:42:39 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 TestRBlend(TestCase):
  10. """Test r.blend script"""
  11. map1 = 'aspect'
  12. map2 = 'elevation'
  13. temp1 = 'elev_shade_blend.r'
  14. temp2 = 'elev_shade_blend.g'
  15. temp3 = 'elev_shade_blend.b'
  16. @classmethod
  17. def setUpClass(cls):
  18. """Create maps in a small region."""
  19. cls.use_temp_region()
  20. cls.runModule('g.region', raster=cls.map1, flags='p')
  21. run_command('d.mon', start='wx0')
  22. @classmethod
  23. def tearDownClass(cls):
  24. """Remove temporary region"""
  25. cls.runModule('g.remove', flags='f', type='raster',
  26. name=(cls.temp1, cls.temp2, cls.temp3))
  27. cls.del_temp_region()
  28. run_command('d.mon', stop='wx0')
  29. def test_blend(self):
  30. """blends color test"""
  31. module = SimpleModule('r.blend', first=self.map1, second=self.map2,
  32. output='elev_shade_blend')
  33. self.assertModule(module)
  34. run_command('d.rgb', red=self.temp1, green=self.temp2,
  35. blue=self.temp3)
  36. if __name__ == '__main__':
  37. test()