test_r_reclass_area.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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(
  28. "r.reclass.area",
  29. input=self.input,
  30. output=self.output + "Greater",
  31. value=self.value,
  32. mode="greater",
  33. method="reclass",
  34. )
  35. self.assertRasterMinMax(
  36. map=self.output + "Greater",
  37. refmin=200,
  38. refmax=1000,
  39. msg="Range of data: min = 200 max = 1000",
  40. )
  41. def test_reclassareaLesser(self):
  42. """Testing r.reclass.area with lesser"""
  43. self.assertModule(
  44. "r.reclass.area",
  45. input=self.input,
  46. output=self.output + "Lesser",
  47. value=self.value,
  48. mode="lesser",
  49. method="reclass",
  50. )
  51. self.assertRasterMinMax(
  52. map=self.output + "Lesser",
  53. refmin=900,
  54. refmax=1000,
  55. msg="Range of data: min = 900 max = 1000",
  56. )
  57. if __name__ == "__main__":
  58. test()