test_v_centroids.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. """
  2. Created on Thrs Jun 09 11:26:12 2018
  3. @author: Sanjeet Bhatti
  4. """
  5. from grass.gunittest.case import TestCase
  6. from grass.gunittest.main import test
  7. from grass.gunittest.gmodules import SimpleModule
  8. class TestVCentroids(TestCase):
  9. """Test v.centroids script"""
  10. mapName = "busroute11"
  11. outRouteMap = "busroute11_boundary"
  12. fromType = "line"
  13. toType = "boundary"
  14. outAreaMap = "busroute11_area"
  15. @classmethod
  16. def setUpClass(cls):
  17. """Create an area from a closed line"""
  18. cls.runModule(
  19. "v.type",
  20. input=cls.mapName,
  21. output=cls.outRouteMap,
  22. from_type=cls.fromType,
  23. to_type=cls.toType,
  24. )
  25. @classmethod
  26. def tearDownClass(cls):
  27. """Remove the generated maps"""
  28. cls.runModule(
  29. "g.remove", flags="f", type="vector", name=(cls.outRouteMap, cls.outAreaMap)
  30. )
  31. def test_area(self):
  32. """Adds missing centroids to closed boundaries test"""
  33. module = SimpleModule(
  34. "v.centroids", input=self.outRouteMap, output=self.outAreaMap
  35. )
  36. self.assertModule(module)
  37. self.assertVectorExists(self.outAreaMap)
  38. if __name__ == "__main__":
  39. test()