test_r_to_vect.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. """
  2. Name: r.to.vect test
  3. Purpose: Tests r.to.vect 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. from grass.gunittest.main import test
  12. from grass.gunittest.gmodules import SimpleModule
  13. class Testrr(TestCase):
  14. input='lakes'
  15. output='testrtovect'
  16. point='point'
  17. area="area"
  18. @classmethod
  19. def setUpClass(cls):
  20. cls.use_temp_region()
  21. cls.runModule('g.region', raster=cls.input)
  22. @classmethod
  23. def tearDownClass(cls):
  24. cls.del_temp_region()
  25. def tearDown(cls):
  26. cls.runModule('g.remove', type='vector', flags='f', name=cls.output)
  27. def test_flags(self):
  28. """Testing flag s"""
  29. self.assertModule('r.to.vect', input=self.input, output=self.output, type=self.point, flags='s')
  30. topology = dict(points=36011, lines=0, areas=0)
  31. self.assertVectorFitsTopoInfo(self.output, topology)
  32. def test_flagz(self):
  33. """Testing flag z"""
  34. self.assertModule('r.to.vect', input=self.input, output=self.output, type=self.point, flags='z')
  35. topology = dict(points=36011, lines=0, areas=0)
  36. self.assertVectorFitsTopoInfo(self.output, topology)
  37. def test_flagb(self):
  38. """Testing flag b"""
  39. self.assertModule('r.to.vect', input=self.input, output=self.output, type=self.area, flags='b')
  40. topology = dict(points=0, lines=0, areas=0)
  41. self.assertVectorFitsTopoInfo(self.output, topology)
  42. def test_flagt(self):
  43. """Testing flag t"""
  44. self.assertModule('r.to.vect', input=self.input, output=self.output, type=self.area, flags='t')
  45. topology = dict(points=0, lines=0, areas=33)
  46. self.assertVectorFitsTopoInfo(self.output, topology)
  47. if __name__ == '__main__':
  48. from grass.gunittest.main import test
  49. test()