test_v_select.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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(
  31. "v.select",
  32. ainput=self.ainput,
  33. binput=self.binput,
  34. output=self.output,
  35. operator="overlap",
  36. )
  37. topology = dict(points=1088, lines=0, areas=0)
  38. self.assertVectorFitsTopoInfo(self.overlap, topology)
  39. def test_opd(self):
  40. """Testign operator disjoint"""
  41. self.assertModule(
  42. "v.select",
  43. ainput=self.ainput,
  44. binput=self.binput,
  45. output=self.output,
  46. operator="disjoint",
  47. )
  48. topology = dict(points=167, lines=0, areas=0)
  49. self.assertVectorFitsTopoInfo(self.disjoint, topology)
  50. def test_ope(self):
  51. """Testing operator equals"""
  52. self.assertModule(
  53. "v.select",
  54. ainput=self.ainput,
  55. binput=self.binput,
  56. output=self.output,
  57. operator="equals",
  58. )
  59. topology = dict(points=0, lines=49746, areas=0)
  60. self.assertVectorFitsTopoInfo(self.equals, topology)
  61. def test_opt(self):
  62. """Testing operator touches"""
  63. self.assertModule(
  64. "v.select",
  65. ainput=self.ainput,
  66. binput=self.binput,
  67. output=self.output,
  68. operator="touches",
  69. )
  70. topology = dict(points=0, lines=0, areas=48)
  71. self.assertVectorFitsTopoInfo(self.touches, topology)
  72. def test_opw(self):
  73. """Testing operator within"""
  74. self.assertModule(
  75. "v.select",
  76. ainput=self.ainput,
  77. binput=self.binput,
  78. output=self.output,
  79. operator="within",
  80. )
  81. topology = dict(points=1088, lines=0, areas=0)
  82. self.assertVectorFitsTopoInfo(self.within, topology)
  83. if __name__ == "__main__":
  84. from grass.gunittest.main import test
  85. test()