test_texture.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. """
  2. Name: r.texture test
  3. Purpose: Tests r.texture and its flags/options.
  4. Author: Sunveer Singh, Google Code-in 2017
  5. Copyright: (C) 2017 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. class TestRasterreport(TestCase):
  12. input = "lsat7_2002_80"
  13. @classmethod
  14. def setUpClass(cls):
  15. cls.use_temp_region()
  16. cls.runModule("g.region", raster=cls.input)
  17. @classmethod
  18. def tearDownClass(cls):
  19. cls.del_temp_region()
  20. cls.runModule('g.remove', flags='f', type='raster', name="asm_ASM")
  21. cls.runModule('g.remove', flags='f', type='raster', name='corr_Corr')
  22. cls.runModule('g.remove', flags='f', type='raster', name='sa_SA')
  23. cls.runModule('g.remove', flags='f', type='raster', name='var_Var')
  24. cls.runModule('g.remove', flags='f', type='raster', name='idm_IDM')
  25. def test_asm(self):
  26. """Testing method asm"""
  27. asm_ASM='asm_ASM'
  28. string="""min=1
  29. max=1
  30. cells=1000246"""
  31. self.assertModule('r.texture', input=self.input, output='asm', method='asm')
  32. self.assertRasterFitsUnivar(asm_ASM,
  33. reference=string, precision=2)
  34. def test_corr(self):
  35. """Testing method corr"""
  36. corr_output='corr_Corr'
  37. string="""min=1
  38. max=1
  39. cells=1000246"""
  40. self.assertModule('r.texture', input=self.input, output='corr', method='corr')
  41. self.assertRasterFitsUnivar(corr_output,
  42. reference=string, precision=2)
  43. def test_sa(self):
  44. """Testing method sa"""
  45. sa_SA='sa_SA'
  46. string="""min=95.95
  47. max=2942.79
  48. cells=1000246"""
  49. self.assertModule('r.texture', input=self.input, output='sa', method='sa')
  50. self.assertRasterFitsUnivar(sa_SA,
  51. reference=string, precision=2)
  52. def test_var(self):
  53. """Testing method var"""
  54. var_output='var_Var'
  55. self.assertModule('r.texture', input=self.input, output='var', method='var')
  56. self.assertRasterMinMax(map=var_output, refmin=0, refmax=9843.07,
  57. msg="var_Var in degrees must be between 0.74 and 9843.07")
  58. def test_idm(self):
  59. """Testing method idm"""
  60. idm_IDM='idm_IDM'
  61. self.assertModule('r.texture', input=self.input, output='idm', method='idm')
  62. self.assertRasterMinMax(map=idm_IDM, refmin=0, refmax=9843.07,
  63. msg="idm_IDM_IDM in degrees must be between 0.74 and 9843.07")
  64. if __name__ == '__main__':
  65. from grass.gunittest.main import test
  66. test()