test_isegment.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. Name: i.segment test
  3. Purpose: Tests i.segment and its flags/options.
  4. Author: Markus Neteler
  5. Copyright: (C) 2018 by Markus Neteler 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 TestReport(TestCase):
  12. @classmethod
  13. def setUpClass(cls):
  14. """Use temporary region settings"""
  15. map_input = 'ortho_2001_t792_1m'
  16. cls.runModule("g.region", n=220000, s=219456, w=637033, e=638000, align=map_input)
  17. cls.use_temp_region()
  18. @classmethod
  19. def tearDownClass(cls):
  20. map_output = 'test'
  21. group = 'ortho'
  22. cls.runModule("g.remove", flags='f', type='raster', name=map_output)
  23. cls.runModule("g.remove", flags='f', type='group', name=group)
  24. cls.del_temp_region()
  25. def test_isegment(self):
  26. """Testing i.segment"""
  27. map_input = 'ortho_2001_t792_1m'
  28. map_output = 'test'
  29. group = 'ortho'
  30. self.assertModule('i.group', group=group, input=map_input)
  31. self.assertModule('i.segment', group=group, threshold=0.01, minsize=1, output=map_output)
  32. self.assertRasterMinMax(map=map_output, refmin=1, refmax=500000,
  33. msg="Number of segments must be > 0")
  34. if __name__ == '__main__':
  35. from grass.gunittest.main import test
  36. test()