test_v_net.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from grass.gunittest.case import TestCase
  2. from grass.gunittest.main import test
  3. from grass.script.core import read_command
  4. class TestVNet(TestCase):
  5. network = 'test_vnet'
  6. def tearDown(cls):
  7. """Remove viewshed map after each test method"""
  8. # TODO: eventually, removing maps should be handled through testing framework fucntions
  9. cls.runModule('g.remove', flags='f', type='vector',
  10. name=cls.network)
  11. def test_nodes(self):
  12. """Test"""
  13. self.assertModule('v.net', input='streets', output=self.network, operation='nodes')
  14. topology = dict(points=41813, nodes=41813, lines=49746)
  15. self.assertVectorFitsTopoInfo(vector=self.network, reference=topology)
  16. layers = read_command('v.category', input=self.network, option='layers').strip()
  17. self.assertEqual(first="1", second=layers, msg="Layers do not match")
  18. def test_nodes_layers(self):
  19. """Test"""
  20. self.assertModule('v.net', input='streets', output=self.network, operation='nodes', flags='c')
  21. topology = dict(points=41813, nodes=41813, lines=49746)
  22. self.assertVectorFitsTopoInfo(vector=self.network, reference=topology)
  23. layers = read_command('v.category', input=self.network, option='layers').strip()
  24. self.assertEqual(first="1\n2", second=layers, msg="Layers do not match")
  25. def test_connect(self):
  26. """Test"""
  27. self.assertModule('v.net', input='streets', points='schools',
  28. output=self.network, operation='connect', threshold=1000)
  29. topology = dict(points=167, nodes=42136, lines=50069)
  30. self.assertVectorFitsTopoInfo(vector=self.network, reference=topology)
  31. layers = read_command('v.category', input=self.network, option='layers').strip()
  32. self.assertEqual(first="1\n2", second=layers, msg="Layers do not match")
  33. def test_connect_snap(self):
  34. """Test"""
  35. self.assertModule('v.net', input='streets', points='schools', flags='s',
  36. output=self.network, operation='connect', threshold=1000)
  37. topology = dict(points=167, nodes=41969, lines=49902)
  38. self.assertVectorFitsTopoInfo(vector=self.network, reference=topology)
  39. if __name__ == '__main__':
  40. test()