[GRASS-SVN] r71654 - in grass-addons/grass7/raster/r.object.geometry: . testsuite testsuite/data
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Nov 10 07:19:57 PST 2017
Author: mlennert
Date: 2017-11-10 07:19:57 -0800 (Fri, 10 Nov 2017)
New Revision: 71654
Added:
grass-addons/grass7/raster/r.object.geometry/testsuite/
grass-addons/grass7/raster/r.object.geometry/testsuite/data/
grass-addons/grass7/raster/r.object.geometry/testsuite/data/file_meter.csv
grass-addons/grass7/raster/r.object.geometry/testsuite/data/file_pixel.csv
grass-addons/grass7/raster/r.object.geometry/testsuite/r_object_geometry_test.py
grass-addons/grass7/raster/r.object.geometry/testsuite/test_keyvalue_result.txt
Log:
r.object.geometry: add first tests
Added: grass-addons/grass7/raster/r.object.geometry/testsuite/data/file_meter.csv
===================================================================
--- grass-addons/grass7/raster/r.object.geometry/testsuite/data/file_meter.csv (rev 0)
+++ grass-addons/grass7/raster/r.object.geometry/testsuite/data/file_meter.csv 2017-11-10 15:19:57 UTC (rev 71654)
@@ -0,0 +1,4 @@
+cat|area|perimeter|compact_square|compact_circle|fd
+1|750000000.000000|110000.000000|0.995859|1.133071|1.136081
+2|1500000000.000000|160000.000000|0.968246|1.165385|1.134278
+3|750000000.000000|110000.000000|0.995859|1.133071|1.136081
Added: grass-addons/grass7/raster/r.object.geometry/testsuite/data/file_pixel.csv
===================================================================
--- grass-addons/grass7/raster/r.object.geometry/testsuite/data/file_pixel.csv (rev 0)
+++ grass-addons/grass7/raster/r.object.geometry/testsuite/data/file_pixel.csv 2017-11-10 15:19:57 UTC (rev 71654)
@@ -0,0 +1,4 @@
+cat|area|perimeter|compact_square|compact_circle|fd
+1|4.000000|8.000000|1.000000|1.128379|2.999459
+2|8.000000|12.000000|0.942809|1.196827|2.389831
+3|4.000000|8.000000|1.000000|1.128379|2.999459
Added: grass-addons/grass7/raster/r.object.geometry/testsuite/r_object_geometry_test.py
===================================================================
--- grass-addons/grass7/raster/r.object.geometry/testsuite/r_object_geometry_test.py (rev 0)
+++ grass-addons/grass7/raster/r.object.geometry/testsuite/r_object_geometry_test.py 2017-11-10 15:19:57 UTC (rev 71654)
@@ -0,0 +1,112 @@
+"""
+Name: r_object_geometry_test
+Purpose: This script is to demonstrate a unit test for r.object.geometry
+ module.
+"""
+
+import os
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+
+testraster1 = """\
+north: 250000
+south: 200000
+east: 670000
+west: 610000
+rows: 4
+cols: 4
+
+1 1 2 2
+1 1 2 2
+3 3 2 2
+3 3 2 2
+"""
+
+class TestObjectGeometryPixel(TestCase):
+ """Test case for object geometry module"""
+
+ # Setup variables to be used for outputs
+ test_objects1 = 'test_objects1'
+ output_file_pixel = 'output_file_pixel.csv'
+
+ @classmethod
+ def setUpClass(cls):
+ """Imports test raster(s), ensures expected computational region and setup"""
+ cls.runModule('r.in.ascii', input='-', stdin_=testraster1,
+ output=cls.test_objects1)
+ cls.use_temp_region()
+ cls.runModule('g.region', raster=cls.test_objects1)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region"""
+ cls.del_temp_region()
+
+ def tearDown(self):
+ """Remove the outputs created from the object geometry module
+
+ This is executed after each test run.
+ """
+ if os.path.isfile(self.output_file_pixel):
+ os.remove(self.output_file_pixel)
+ self.runModule('g.remove', flags='f', type='raster',
+ name=self.test_objects1)
+
+ def test_object_geometry_pixel(self):
+ """Test to see if the outputs are created and are correct in pixel units"""
+ # run the object geometry module
+ self.assertModule('r.object.geometry', input=self.test_objects1,
+ output=self.output_file_pixel)
+ # check to see if output file exists
+ self.assertFileExists(self.output_file_pixel,
+ msg='Output file does not exist')
+ # check if the output file is equal to the reference file
+ self.assertFilesEqualMd5(self.output_file_pixel, 'data/file_pixel.csv',
+ msg='Output file is not equal to reference file')
+
+class TestObjectGeometryMeter(TestCase):
+ """Test case for object geometry module"""
+
+ # Setup variables to be used for outputs
+ test_objects1 = 'test_objects1'
+ output_file_meter = 'output_file_meter.csv'
+
+ @classmethod
+ def setUpClass(cls):
+ """Imports test raster(s), ensures expected computational region and setup"""
+ cls.runModule('r.in.ascii', input='-', stdin_=testraster1,
+ output=cls.test_objects1)
+ cls.use_temp_region()
+ cls.runModule('g.region', raster=cls.test_objects1)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove the temporary region"""
+ cls.del_temp_region()
+
+ def tearDown(self):
+ """Remove the outputs created from the object geometry module
+
+ This is executed after each test run.
+ """
+ if os.path.isfile(self.output_file_meter):
+ os.remove(self.output_file_meter)
+ self.runModule('g.remove', flags='f', type='raster',
+ name=self.test_objects1)
+
+ def test_object_geometry_meter(self):
+ """Test to see if the outputs are created and are correct in meter units"""
+ # run the object geometry module
+ self.assertModule('r.object.geometry', input=self.test_objects1,
+ output=self.output_file_meter, flags='m')
+ # check to see if output file exists
+ self.assertFileExists(self.output_file_meter,
+ msg='Output file does not exist')
+ # check if the output file is equal to the reference file
+ self.assertFilesEqualMd5(self.output_file_meter, 'data/file_meter.csv',
+ msg='Output file is not equal to reference file')
+
+
+
+if __name__ == '__main__':
+ test()
Added: grass-addons/grass7/raster/r.object.geometry/testsuite/test_keyvalue_result.txt
===================================================================
--- grass-addons/grass7/raster/r.object.geometry/testsuite/test_keyvalue_result.txt (rev 0)
+++ grass-addons/grass7/raster/r.object.geometry/testsuite/test_keyvalue_result.txt 2017-11-10 15:19:57 UTC (rev 71654)
@@ -0,0 +1,12 @@
+time=0.571s
+status=succeeded
+total=2
+failures=0
+errors=0
+successes=2
+skipped=0
+expected_failures=0
+unexpected_successes=0
+tested_modules=r.object.geometry,r.object.geometry
+supplementary_files=
+test_type=not-specified
More information about the grass-commit
mailing list