test_v_select.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. """
  2. Name: v.select test
  3. Purpose: Tests v.select 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. binput = "bridges"
  13. ainput = "geology"
  14. output = "testvselect"
  15. overlap = "geonames_wake"
  16. disjoint = "schools_wake"
  17. equals = "streets_wake"
  18. touches = "zipcodes_wake"
  19. within = "geonames_wake"
  20. @classmethod
  21. def setUpClass(cls):
  22. cls.use_temp_region()
  23. @classmethod
  24. def tearDownClass(cls):
  25. cls.del_temp_region()
  26. def tearDown(cls):
  27. cls.runModule('g.remove', type='vector', flags='f', name=cls.output)
  28. def test_opo(self):
  29. """Testing operator overlap"""
  30. self.assertModule('v.select', ainput=self.ainput, binput=self.binput,
  31. output=self.output, operator='overlap')
  32. topology = dict(points=1088, lines=0, areas=0)
  33. self.assertVectorFitsTopoInfo(self.overlap, topology)
  34. def test_opd(self):
  35. """Testign operator disjoint """
  36. self.assertModule('v.select', ainput=self.ainput, binput=self.binput,
  37. output=self.output, operator='disjoint')
  38. topology = dict(points=167, lines=0, areas=0)
  39. self.assertVectorFitsTopoInfo(self.disjoint, topology)
  40. def test_ope(self):
  41. """Testing operator equals """
  42. self.assertModule('v.select', ainput=self.ainput, binput=self.binput,
  43. output=self.output, operator='equals')
  44. topology = dict(points=0, lines=49746, areas=0)
  45. self.assertVectorFitsTopoInfo(self.equals, topology)
  46. def test_opt(self):
  47. """Testing operator touches"""
  48. self.assertModule('v.select', ainput=self.ainput, binput=self.binput,
  49. output=self.output, operator='touches')
  50. topology = dict(points=0, lines=0, areas=48)
  51. self.assertVectorFitsTopoInfo(self.touches, topology)
  52. def test_opw(self):
  53. """Testing operator within"""
  54. self.assertModule('v.select', ainput=self.ainput, binput=self.binput,
  55. output=self.output, operator='within')
  56. topology = dict(points=1088, lines=0, areas=0)
  57. self.assertVectorFitsTopoInfo(self.within, topology)
  58. if __name__ == '__main__':
  59. from grass.gunittest.main import test
  60. test()