testrra.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """
  2. Name: r.reclass.area test
  3. Purpose: Tests r.reclass.area and its flags/options.
  4. Author: Sunveer Singh, Google Code-in 2018
  5. Copyright: (C) 2018 by Sunveer Singh 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 Testrr(TestCase):
  13. input='zipcodes'
  14. output='rraoutput'
  15. @classmethod
  16. def setUpClass(cls):
  17. cls.use_temp_region()
  18. cls.runModule('g.region', raster=cls.input)
  19. @classmethod
  20. def tearDownClass(cls):
  21. cls.del_temp_region()
  22. def tearDown(cls):
  23. cls.runModule('g.remove', type='raster', flags='f', name=cls.output)
  24. def test_flag_c(self):
  25. """Testing flag c"""
  26. string="""min=27603
  27. max=27607
  28. cells=2025000"""
  29. self.assertModule('r.reclass.area', input=self.input, output=self.output, value=2000, mode="greater", flags='c')
  30. self.assertRasterFitsUnivar(self.output,
  31. reference=string, precision=2)
  32. def test_flag_d(self):
  33. """Testing flag d"""
  34. self.assertModule('r.reclass.area', input=self.input, output=self.output, value=2000, mode="lesser", flags='d')
  35. self.assertRasterMinMax(map=self.output, refmin=27511, refmax=27610,
  36. msg="Output Map in degrees must be between 27511 and 27610")
  37. def test_module_output(self):
  38. """Testing Module without flags"""
  39. self.assertModule('r.reclass.area', input=self.input, output=self.output, value=2000, mode="greater")
  40. self.assertRasterMinMax(map=self.output, refmin=27603, refmax=27607,
  41. msg="Output Map in degrees must be between 27603 and 27607")
  42. def test_method_rmarea(self):
  43. """Testing Module without flags"""
  44. self.assertModule('r.reclass.area', input=self.input, output=self.output, value=2000, mode="lesser", method="rmarea")
  45. self.assertRasterMinMax(map=self.output, refmin=27603, refmax=27607,
  46. msg="Output Map in degrees must be between 27603 and 27607")
  47. if __name__ == '__main__':
  48. from grass.gunittest.main import test
  49. test()