test_v_centroids.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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('v.type', input=cls.mapName, output=cls.outRouteMap,
  19. from_type=cls.fromType, to_type=cls.toType)
  20. @classmethod
  21. def tearDownClass(cls):
  22. """Remove the generated maps"""
  23. cls.runModule('g.remove', flags='f', type='vector',
  24. name=(cls.outRouteMap, cls.outAreaMap))
  25. def test_area(self):
  26. """Adds missing centroids to closed boundaries test"""
  27. module = SimpleModule('v.centroids', input=self.outRouteMap,
  28. output=self.outAreaMap)
  29. self.assertModule(module)
  30. self.assertVectorExists(self.outAreaMap)
  31. if __name__ == '__main__':
  32. test()