diff --git a/vector/v.random/testsuite/test_v_random.py b/vector/v.random/testsuite/test_v_random.py index 6728a476a..a5163d31f 100644 --- a/vector/v.random/testsuite/test_v_random.py +++ b/vector/v.random/testsuite/test_v_random.py @@ -1,39 +1,48 @@ -#!/usr/bin/env python3 - -from grass.gunittest.case import TestCase -from grass.gunittest.main import test - -output = 'test01' -npoints = 100 -state = 'boundary_state' -zmin=10 -zmax=120 - -class Test_v_random(TestCase): - - @classmethod - def setUpClass(cls): - cls.use_temp_region() - cls.runModule('g.region', vector=state) - - @classmethod - def tearDownClass(cls): - cls.del_temp_region() - - def test_num_points(self): - self.assertModule('v.random', output=output, npoints=npoints, - overwrite=True) - - topology = dict(points=npoints) - self.assertVectorFitsTopoInfo(vector=output, reference=topology) - - def test_num_points_3D(self): - self.assertModule('v.random', output=output, npoints=npoints, - zmin=zmin, zmax=zmax, - overwrite=True, flags='z') - - topology = dict(points=npoints, map3d=1) - self.assertVectorFitsTopoInfo(vector=output, reference=topology) - -if __name__ == '__main__': - test() +#!/usr/bin/env python3 + +from grass.gunittest.case import TestCase +from grass.gunittest.main import test + +output = 'test01' +output2 = 'test02' +npoints = 100 +state = 'boundary_state' +zmin=10 +zmax=120 + +class Test_v_random(TestCase): + + @classmethod + def setUpClass(cls): + cls.use_temp_region() + cls.runModule('g.region', vector=state) + + @classmethod + def tearDownClass(cls): + cls.del_temp_region() + + #Checking if number of points equals 100 + def test_num_points(self): + self.assertModule('v.random', output=output, npoints=npoints, + overwrite=True) + + topology = dict(points=npoints) + self.assertVectorFitsTopoInfo(vector=output, reference=topology) + #Checking if the map is 3D and number of points is 100 + def test_num_points_3D(self): + self.assertModule('v.random', output=output, npoints=npoints, + zmin=zmin, zmax=zmax, + overwrite=True, flags='z') + + topology = dict(points=npoints, map3d=1) + self.assertVectorFitsTopoInfo(vector=output, reference=topology) + #Checking if all points are in the polygon boundary state + def test_restrict(self): + self.assertModule('v.random', output=output, npoints=npoints, + restrict=state, overwrite=True) + self.assertModule('v.clip', input=output, clip=state, + overwrite=True, output=output2) + self.assertVectorInfoEqualsVectorInfo(output,output2,precision=0.01) + +if __name__ == '__main__': + test()