test_r_mask.py 1011 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. Created on Sun Jun 07 22:19: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. class TestRMask(TestCase):
  9. """Test r.mask script"""
  10. mapName = "lakes"
  11. mapNameOther = "elevation"
  12. values = "min=56.8785\nmax=134.87"
  13. @classmethod
  14. def setUpClass(cls):
  15. """Create maps in a small region."""
  16. cls.use_temp_region()
  17. cls.runModule("g.region", raster=cls.mapName, flags="p")
  18. @classmethod
  19. def tearDownClass(cls):
  20. """Remove temporary region. Remove mask"""
  21. cls.del_temp_region()
  22. cls.runModule("r.mask", flags="r")
  23. def test_mask(self):
  24. """Mask test"""
  25. module = SimpleModule("r.mask", raster=self.mapName)
  26. self.assertModule(module)
  27. self.assertRasterFitsUnivar(
  28. raster=self.mapNameOther, reference=self.values, precision=5
  29. )
  30. if __name__ == "__main__":
  31. test()