Skip to content

Commit

Permalink
Upgrade of testsuit for v_random #6
Browse files Browse the repository at this point in the history
Adding resctrict test for v.random #6

Co-Authored-By: dekanluc <[email protected]>
  • Loading branch information
JosefPudil and dekanluc committed Jun 2, 2020
1 parent f7b57a9 commit 683ae5e
Showing 1 changed file with 48 additions and 39 deletions.
87 changes: 48 additions & 39 deletions vector/v.random/testsuite/test_v_random.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 683ae5e

Please sign in to comment.