[GRASS-SVN] r62297 - in grass/trunk/vector/v.what: . testsuite testsuite/data

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 19 15:15:39 PDT 2014


Author: annakrat
Date: 2014-10-19 15:15:39 -0700 (Sun, 19 Oct 2014)
New Revision: 62297

Added:
   grass/trunk/vector/v.what/testsuite/
   grass/trunk/vector/v.what/testsuite/data/
   grass/trunk/vector/v.what/testsuite/data/table1.csv
   grass/trunk/vector/v.what/testsuite/data/table1.csvt
   grass/trunk/vector/v.what/testsuite/data/table2.csv
   grass/trunk/vector/v.what/testsuite/data/table2.csvt
   grass/trunk/vector/v.what/testsuite/data/testing.ascii
   grass/trunk/vector/v.what/testsuite/test_vwhat_layers.py
   grass/trunk/vector/v.what/testsuite/test_vwhat_ncspm.py
Log:
v.what: added testsuite

Added: grass/trunk/vector/v.what/testsuite/data/table1.csv
===================================================================
--- grass/trunk/vector/v.what/testsuite/data/table1.csv	                        (rev 0)
+++ grass/trunk/vector/v.what/testsuite/data/table1.csv	2014-10-19 22:15:39 UTC (rev 62297)
@@ -0,0 +1,2 @@
+cat,text,number
+1,"xxx",6

Added: grass/trunk/vector/v.what/testsuite/data/table1.csvt
===================================================================
--- grass/trunk/vector/v.what/testsuite/data/table1.csvt	                        (rev 0)
+++ grass/trunk/vector/v.what/testsuite/data/table1.csvt	2014-10-19 22:15:39 UTC (rev 62297)
@@ -0,0 +1 @@
+"Integer","String(5)","Real"

Added: grass/trunk/vector/v.what/testsuite/data/table2.csv
===================================================================
--- grass/trunk/vector/v.what/testsuite/data/table2.csv	                        (rev 0)
+++ grass/trunk/vector/v.what/testsuite/data/table2.csv	2014-10-19 22:15:39 UTC (rev 62297)
@@ -0,0 +1,2 @@
+cat,text,number
+4,yyy,8.09

Added: grass/trunk/vector/v.what/testsuite/data/table2.csvt
===================================================================
--- grass/trunk/vector/v.what/testsuite/data/table2.csvt	                        (rev 0)
+++ grass/trunk/vector/v.what/testsuite/data/table2.csvt	2014-10-19 22:15:39 UTC (rev 62297)
@@ -0,0 +1 @@
+"Integer","String(5)","Real"

Added: grass/trunk/vector/v.what/testsuite/data/testing.ascii
===================================================================
--- grass/trunk/vector/v.what/testsuite/data/testing.ascii	                        (rev 0)
+++ grass/trunk/vector/v.what/testsuite/data/testing.ascii	2014-10-19 22:15:39 UTC (rev 62297)
@@ -0,0 +1,22 @@
+ORGANIZATION: 
+DIGIT DATE:   
+DIGIT NAME:   anna
+MAP NAME:     
+MAP DATE:     Sun Oct 19 16:52:48 2014
+MAP SCALE:    1
+OTHER INFO:   
+ZONE:         0
+MAP THRESH:   0.000000
+VERTI:
+B  5
+ 634316.91751782 226735.12060449
+ 633502.53863122 225868.91760693
+ 634635.26562803 225854.11071808
+ 634716.70351669 226490.80693852
+ 634316.91751782 226735.12060449
+C  1 4
+ 634188.44495779 226174.84200474
+ 1     2         
+ 1     1         
+ 2     3         
+ 2     4         

Added: grass/trunk/vector/v.what/testsuite/test_vwhat_layers.py
===================================================================
--- grass/trunk/vector/v.what/testsuite/test_vwhat_layers.py	                        (rev 0)
+++ grass/trunk/vector/v.what/testsuite/test_vwhat_layers.py	2014-10-19 22:15:39 UTC (rev 62297)
@@ -0,0 +1,149 @@
+# -*- coding: utf-8 -*-
+from grass.gunittest import TestCase, test
+from grass.gunittest.gmodules import SimpleModule
+
+out1 = """East: 634243
+North: 226193
+------------------------------------------------------------------
+Map: test_vector 
+Mapset: vector_what
+Type: Area
+Sq Meters: 633834.281
+Hectares: 63.383
+Acres: 156.624
+Sq Miles: 0.2447
+Layer: 1
+Category: 2
+Layer: 1
+Category: 1
+Layer: 2
+Category: 3
+Layer: 2
+Category: 4
+"""
+
+
+out2 = """East: 634243
+North: 226193
+------------------------------------------------------------------
+Map: test_vector 
+Mapset: vector_what
+Type: Area
+Sq Meters: 633834.281
+Hectares: 63.383
+Acres: 156.624
+Sq Miles: 0.2447
+Layer: 1
+Category: 2
+
+Driver: sqlite
+Database: /home/anna/grassdata/nc_spm_08_grass7_test/vector_what/sqlite/sqlite.db
+Table: t1
+Key column: cat_
+Layer: 1
+Category: 1
+
+Driver: sqlite
+Database: /home/anna/grassdata/nc_spm_08_grass7_test/vector_what/sqlite/sqlite.db
+Table: t1
+Key column: cat_
+cat_ : 1
+text : xxx
+number : 6
+Layer: 2
+Category: 3
+
+Driver: sqlite
+Database: /home/anna/grassdata/nc_spm_08_grass7_test/vector_what/sqlite/sqlite.db
+Table: t2
+Key column: cat_
+Layer: 2
+Category: 4
+
+Driver: sqlite
+Database: /home/anna/grassdata/nc_spm_08_grass7_test/vector_what/sqlite/sqlite.db
+Table: t2
+Key column: cat_
+cat_ : 4
+text : yyy
+number : 8.09
+"""
+
+out3 = """East=634243
+North=226193
+
+Map=test_vector
+Mapset=vector_what
+Type=Area
+Sq_Meters=633834.281
+Hectares=63.383
+Acres=156.624
+Sq_Miles=0.2447
+Layer=1
+Category=2
+Driver=sqlite
+Database=/home/anna/grassdata/nc_spm_08_grass7_test/vector_what/sqlite/sqlite.db
+Table=t1
+Key_column=cat_
+Layer=1
+Category=1
+Driver=sqlite
+Database=/home/anna/grassdata/nc_spm_08_grass7_test/vector_what/sqlite/sqlite.db
+Table=t1
+Key_column=cat_
+cat_=1
+text=xxx
+number=6
+Layer=2
+Category=3
+Driver=sqlite
+Database=/home/anna/grassdata/nc_spm_08_grass7_test/vector_what/sqlite/sqlite.db
+Table=t2
+Key_column=cat_
+Layer=2
+Category=4
+Driver=sqlite
+Database=/home/anna/grassdata/nc_spm_08_grass7_test/vector_what/sqlite/sqlite.db
+Table=t2
+Key_column=cat_
+cat_=4
+text=yyy
+number=8.09
+"""
+
+
+class TestMultiLayerMap(TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.runModule('v.in.ascii', input='./data/testing.ascii', output='test_vector',
+                      format='standard')
+        cls.runModule('db.in.ogr', dsn='./data/table1.csv', output='t1')
+        cls.runModule('db.in.ogr', dsn='./data/table2.csv', output='t2')
+        cls.runModule('v.db.connect', map='test_vector', table='t1', key='cat_', layer=1)
+        cls.runModule('v.db.connect', map='test_vector', table='t2', key='cat_', layer=2)
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.runModule('g.remove', type='vect', names='test_vector', flags='f')
+
+    def setUp(self):
+        self.vwhat = SimpleModule('v.what', map='test_vector',
+                                  coordinates=[634243, 226193], distance=10)
+
+    def test_run(self):
+        self.assertModule(self.vwhat)
+        self.assertMultiLineEqual(first=out1, second=self.vwhat.outputs.stdout)
+
+    def test_print_options(self):
+        self.vwhat.flags['a'].value = True
+        self.assertModule(self.vwhat)
+        self.assertMultiLineEqual(first=out2, second=self.vwhat.outputs.stdout)
+
+        self.vwhat.flags['g'].value = True
+        self.assertModule(self.vwhat)
+        self.assertMultiLineEqual(first=out3, second=self.vwhat.outputs.stdout)
+
+
+if __name__ == '__main__':
+    test()


Property changes on: grass/trunk/vector/v.what/testsuite/test_vwhat_layers.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native

Added: grass/trunk/vector/v.what/testsuite/test_vwhat_ncspm.py
===================================================================
--- grass/trunk/vector/v.what/testsuite/test_vwhat_ncspm.py	                        (rev 0)
+++ grass/trunk/vector/v.what/testsuite/test_vwhat_ncspm.py	2014-10-19 22:15:39 UTC (rev 62297)
@@ -0,0 +1,239 @@
+# -*- coding: utf-8 -*-
+from grass.gunittest import TestCase, test
+from grass.gunittest.gmodules import SimpleModule
+
+
+out1 = """East: 636661
+North: 226489
+------------------------------------------------------------------
+Map: roadsmajor 
+Mapset: PERMANENT
+Type: Line
+Id: 231
+Length: 2321.407296
+Layer: 1
+Category: 231
+------------------------------------------------------------------
+Map: precip_30ynormals_3d 
+Mapset: PERMANENT
+Type: Point
+Id: 96
+Point height: 121.920000
+Layer: 1
+Category: 96
+------------------------------------------------------------------
+Map: lakes 
+Mapset: PERMANENT
+Type: Area
+Sq Meters: 9397.338
+Hectares: 0.940
+Acres: 2.322
+Sq Miles: 0.0036
+Layer: 1
+Category: 7168
+"""
+
+out2 = """East: 636661
+North: 226489
+------------------------------------------------------------------
+Map: roadsmajor 
+Mapset: PERMANENT
+Type: Line
+Id: 231
+Length: 2321.407296
+Layer: 1
+Category: 231
+
+Driver: sqlite
+Database: /home/anna/grassdata/nc_spm_08_grass7_test/PERMANENT/sqlite/sqlite.db
+Table: roadsmajor
+Key column: cat
+cat : 231
+MAJORRDS_ : 233
+ROAD_NAME : I-440
+MULTILANE : yes
+PROPYEAR : 2015
+OBJECTID : 231
+SHAPE_LEN : 7616.150435
+------------------------------------------------------------------
+Map: precip_30ynormals_3d 
+Mapset: PERMANENT
+Type: Point
+Id: 96
+Point height: 121.920000
+Layer: 1
+Category: 96
+
+Driver: sqlite
+Database: /home/anna/grassdata/nc_spm_08_grass7_test/PERMANENT/sqlite/sqlite.db
+Table: precip_30ynormals_3d
+Key column: cat
+cat : 96
+station : 317079
+lat : 35.79444
+long : -78.69889
+elev : 121.92
+jan : 113.284
+feb : 89.662
+mar : 113.284
+apr : 75.692
+may : 102.362
+jun : 103.124
+jul : 110.49
+aug : 109.22
+sep : 108.458
+oct : 96.012
+nov : 77.724
+dec : 81.534
+annual : 1178.56
+------------------------------------------------------------------
+Map: lakes 
+Mapset: PERMANENT
+Type: Area
+Sq Meters: 9397.338
+Hectares: 0.940
+Acres: 2.322
+Sq Miles: 0.0036
+Layer: 1
+Category: 7168
+
+Driver: sqlite
+Database: /home/anna/grassdata/nc_spm_08_grass7_test/PERMANENT/sqlite/sqlite.db
+Table: lakes
+Key column: cat
+cat : 7168
+AREA : 101151.70356
+PERIMETER : 1549.92239
+FULL_HYDRO : 7169
+FULL_HYDR2 : 157379
+FTYPE : LAKE/POND
+FCODE : 39000
+NAME : 
+"""
+
+out3 = """East=636661
+North=226489
+
+Map=roadsmajor
+Mapset=PERMANENT
+Type=Line
+Id=231
+Length=2321.407296
+Layer=1
+Category=231
+Driver=sqlite
+Database=/home/anna/grassdata/nc_spm_08_grass7_test/PERMANENT/sqlite/sqlite.db
+Table=roadsmajor
+Key_column=cat
+cat=231
+MAJORRDS_=233
+ROAD_NAME=I-440
+MULTILANE=yes
+PROPYEAR=2015
+OBJECTID=231
+SHAPE_LEN=7616.150435
+
+Map=precip_30ynormals_3d
+Mapset=PERMANENT
+Type=Point
+Id=96
+Point_height=121.920000
+Layer=1
+Category=96
+Driver=sqlite
+Database=/home/anna/grassdata/nc_spm_08_grass7_test/PERMANENT/sqlite/sqlite.db
+Table=precip_30ynormals_3d
+Key_column=cat
+cat=96
+station=317079
+lat=35.79444
+long=-78.69889
+elev=121.92
+jan=113.284
+feb=89.662
+mar=113.284
+apr=75.692
+may=102.362
+jun=103.124
+jul=110.49
+aug=109.22
+sep=108.458
+oct=96.012
+nov=77.724
+dec=81.534
+annual=1178.56
+
+Map=lakes
+Mapset=PERMANENT
+Type=Area
+Sq_Meters=9397.338
+Hectares=0.940
+Acres=2.322
+Sq_Miles=0.0036
+Layer=1
+Category=7168
+Driver=sqlite
+Database=/home/anna/grassdata/nc_spm_08_grass7_test/PERMANENT/sqlite/sqlite.db
+Table=lakes
+Key_column=cat
+cat=7168
+AREA=101151.70356
+PERIMETER=1549.92239
+FULL_HYDRO=7169
+FULL_HYDR2=157379
+FTYPE=LAKE/POND
+FCODE=39000
+NAME=
+"""
+
+out4 = """East: 636661
+North: 226489
+------------------------------------------------------------------
+Map: roadsmajor 
+Mapset: PERMANENT
+Nothing Found.
+------------------------------------------------------------------
+Map: precip_30ynormals_3d 
+Mapset: PERMANENT
+Nothing Found.
+------------------------------------------------------------------
+Map: lakes 
+Mapset: PERMANENT
+Type: Area
+Sq Meters: 9397.338
+Hectares: 0.940
+Acres: 2.322
+Sq Miles: 0.0036
+Layer: 1
+Category: 7168
+"""
+
+
+class TestNCMaps(TestCase):
+
+    def setUp(self):
+        self.vwhat = SimpleModule('v.what', map=['roadsmajor', 'precip_30ynormals_3d', 'lakes'],
+                                  layer=['-1', '-1', '-1'], coordinates=[636661, 226489],
+                                  distance=1000)
+
+    def test_multiple_maps(self):
+        self.assertModule(self.vwhat)
+        self.assertMultiLineEqual(first=out1, second=self.vwhat.outputs.stdout)
+
+    def test_print_options(self):
+        self.vwhat.flags['a'].value = True
+        self.assertModule(self.vwhat)
+        self.assertMultiLineEqual(first=out2, second=self.vwhat.outputs.stdout)
+
+        self.vwhat.flags['g'].value = True
+        self.assertModule(self.vwhat)
+        self.assertMultiLineEqual(first=out3, second=self.vwhat.outputs.stdout)
+
+    def test_threshold(self):
+        self.vwhat.inputs['distance'].value = 100
+        self.assertModule(self.vwhat)
+        self.assertMultiLineEqual(first=out4, second=self.vwhat.outputs.stdout)
+
+
+if __name__ == '__main__':
+    test()
\ No newline at end of file


Property changes on: grass/trunk/vector/v.what/testsuite/test_vwhat_ncspm.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list