|
@@ -0,0 +1,49 @@
|
|
|
|
+import grass.gunittest
|
|
|
|
+from grass.script.core import read_command
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class TestVNet(grass.gunittest.TestCase):
|
|
|
|
+
|
|
|
|
+ network = 'test_vnet'
|
|
|
|
+
|
|
|
|
+ def tearDown(cls):
|
|
|
|
+ """Remove viewshed map after each test method"""
|
|
|
|
+ # TODO: eventually, removing maps should be handled through testing framework fucntions
|
|
|
|
+ cls.runModule('g.remove', flags='f', type='vector',
|
|
|
|
+ name=cls.network)
|
|
|
|
+
|
|
|
|
+ def test_nodes(self):
|
|
|
|
+ """Test"""
|
|
|
|
+ self.assertModule('v.net', input='streets_wake', output=self.network, operation='nodes')
|
|
|
|
+ topology = dict(points=41813, nodes=41813, lines=49746)
|
|
|
|
+ self.assertVectorFitsTopoInfo(vector=self.network, reference=topology)
|
|
|
|
+ layers = read_command('v.category', input=self.network, option='layers').strip()
|
|
|
|
+ self.assertEqual(first="1", second=layers, msg="Layers do not match")
|
|
|
|
+
|
|
|
|
+ def test_nodes_layers(self):
|
|
|
|
+ """Test"""
|
|
|
|
+ self.assertModule('v.net', input='streets_wake', output=self.network, operation='nodes', flags='c')
|
|
|
|
+ topology = dict(points=41813, nodes=41813, lines=49746)
|
|
|
|
+ self.assertVectorFitsTopoInfo(vector=self.network, reference=topology)
|
|
|
|
+ layers = read_command('v.category', input=self.network, option='layers').strip()
|
|
|
|
+ self.assertEqual(first="1\n2", second=layers, msg="Layers do not match")
|
|
|
|
+
|
|
|
|
+ def test_connect(self):
|
|
|
|
+ """Test"""
|
|
|
|
+ self.assertModule('v.net', input='streets_wake', points='schools_wake',
|
|
|
|
+ output=self.network, operation='connect', threshold=1000)
|
|
|
|
+ topology = dict(points=167, nodes=42136, lines=50080)
|
|
|
|
+ self.assertVectorFitsTopoInfo(vector=self.network, reference=topology)
|
|
|
|
+ layers = read_command('v.category', input=self.network, option='layers').strip()
|
|
|
|
+ self.assertEqual(first="1\n2", second=layers, msg="Layers do not match")
|
|
|
|
+
|
|
|
|
+ def test_connect_snap(self):
|
|
|
|
+ """Test"""
|
|
|
|
+ self.assertModule('v.net', input='streets_wake', points='schools_wake', flags='s',
|
|
|
|
+ output=self.network, operation='connect', threshold=1000)
|
|
|
|
+ topology = dict(points=167, nodes=41969, lines=49913)
|
|
|
|
+ self.assertVectorFitsTopoInfo(vector=self.network, reference=topology)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+if __name__ == '__main__':
|
|
|
|
+ grass.gunittest.test()
|