test_r_reclass_area.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """
  2. Name: r.reclass.area test
  3. Purpose: Tests r.reclass.area.
  4. Author: Shubham Sharma, Google Code-in 2018
  5. Copyright: (C) 2018 by Shubham Sharma and the GRASS Development Team
  6. Licence: This program is free software under the GNU General Public
  7. License (>=v2). Read the file COPYING that comes with GRASS
  8. for details.
  9. """
  10. from grass.gunittest.case import TestCase
  11. from grass.gunittest.main import test
  12. class TestReclassArea(TestCase):
  13. input = 'geology_30m'
  14. output = 'reclassarea'
  15. value = '20'
  16. @classmethod
  17. def setUpClass(cls):
  18. cls.use_temp_region()
  19. cls.runModule('g.region', raster=cls.input)
  20. @classmethod
  21. def tearDownClass(cls):
  22. cls.del_temp_region()
  23. cls.runModule('g.remove', type='raster', flags='f', name=cls.output + 'Greater')
  24. cls.runModule('g.remove', type='raster', flags='f', name=cls.output + 'Lesser')
  25. def test_reclassaeaGreater(self):
  26. """Testing r.reclass.area with greater"""
  27. self.assertModule('r.reclass.area', input=self.input, output=self.output + 'Greater',
  28. value=self.value, mode='greater', method='reclass')
  29. self.assertRasterMinMax(map=self.output + 'Greater', refmin=200, refmax=1000,
  30. msg="Range of data: min = 200 max = 1000")
  31. def test_reclassareaLesser(self):
  32. """Testing r.reclass.area with lesser"""
  33. self.assertModule('r.reclass.area', input=self.input, output=self.output + 'Lesser',
  34. value=self.value, mode='lesser', method='reclass')
  35. self.assertRasterMinMax(map=self.output + 'Lesser', refmin=900, refmax=1000,
  36. msg="Range of data: min = 900 max = 1000")
  37. if __name__ == '__main__':
  38. test()