[GRASS-SVN] r63923 - in grass/branches/releasebranch_7_0/vector/v.what: . testsuite testsuite/data

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 1 14:36:28 PST 2015


Author: neteler
Date: 2015-01-01 14:36:28 -0800 (Thu, 01 Jan 2015)
New Revision: 63923

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

Added: grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table1.csv
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table1.csv	                        (rev 0)
+++ grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table1.csv	2015-01-01 22:36:28 UTC (rev 63923)
@@ -0,0 +1,2 @@
+cat,text,number
+1,"Petrášová",6

Added: grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table1.csvt
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table1.csvt	                        (rev 0)
+++ grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table1.csvt	2015-01-01 22:36:28 UTC (rev 63923)
@@ -0,0 +1 @@
+"Integer","String(5)","Real"

Added: grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table2.csv
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table2.csv	                        (rev 0)
+++ grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table2.csv	2015-01-01 22:36:28 UTC (rev 63923)
@@ -0,0 +1,2 @@
+cat,text,number
+4,yyy,8.09

Added: grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table2.csvt
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table2.csvt	                        (rev 0)
+++ grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/table2.csvt	2015-01-01 22:36:28 UTC (rev 63923)
@@ -0,0 +1 @@
+"Integer","String(5)","Real"

Added: grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/testing.ascii
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/testing.ascii	                        (rev 0)
+++ grass/branches/releasebranch_7_0/vector/v.what/testsuite/data/testing.ascii	2015-01-01 22:36:28 UTC (rev 63923)
@@ -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/branches/releasebranch_7_0/vector/v.what/testsuite/test_vwhat_layers.py
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/testsuite/test_vwhat_layers.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/vector/v.what/testsuite/test_vwhat_layers.py	2015-01-01 22:36:28 UTC (rev 63923)
@@ -0,0 +1,160 @@
+# -*- coding: utf-8 -*-
+from grass.gunittest import TestCase, test
+from grass.gunittest.gmodules import SimpleModule
+
+out1 = """East: 634243
+North: 226193
+------------------------------------------------------------------
+Map: test_vector 
+Mapset: ...
+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: ...
+Type: Area
+Sq Meters: 633834.281
+Hectares: 63.383
+Acres: 156.624
+Sq Miles: 0.2447
+Layer: 1
+Category: 2
+
+Driver: ...
+Database: ...
+Table: t1
+Key column: cat_
+Layer: 1
+Category: 1
+
+Driver: ...
+Database: ...
+Table: t1
+Key column: cat_
+cat_ : 1
+text : Petrášová
+number : 6
+Layer: 2
+Category: 3
+
+Driver: ...
+Database: ...
+Table: t2
+Key column: cat_
+Layer: 2
+Category: 4
+
+Driver: ...
+Database: ...
+Table: t2
+Key column: cat_
+cat_ : 4
+text : yyy
+number : 8.09
+"""
+
+out3 = """East=634243
+North=226193
+
+Map=test_vector
+Mapset=...
+Type=Area
+Sq_Meters=633834.281
+Hectares=63.383
+Acres=156.624
+Sq_Miles=0.2447
+Layer=1
+Category=2
+Driver=...
+Database=...
+Table=t1
+Key_column=cat_
+Layer=1
+Category=1
+Driver=...
+Database=...
+Table=t1
+Key_column=cat_
+cat_=1
+text=Petrášová
+number=6
+Layer=2
+Category=3
+Driver=...
+Database=...
+Table=t2
+Key_column=cat_
+Layer=2
+Category=4
+Driver=...
+Database=...
+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.connect', flags='c')
+        cls.runModule('db.in.ogr', input='./data/table1.csv', output='t1')
+        cls.runModule('db.in.ogr', input='./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='vector', name='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.assertLooksLike(reference=out1, actual=self.vwhat.outputs.stdout)
+
+    def test_print_options(self):
+        self.vwhat.flags['a'].value = True
+        self.assertModule(self.vwhat)
+        self.assertLooksLike(reference=out2, actual=self.vwhat.outputs.stdout)
+
+        self.vwhat.flags['g'].value = True
+        self.assertModule(self.vwhat)
+        self.assertLooksLike(reference=out3, actual=self.vwhat.outputs.stdout)
+
+    def test_print_options_json(self):
+        import json
+        self.vwhat.flags['j'].value = True
+        self.vwhat.flags['a'].value = True
+        self.assertModule(self.vwhat)
+        try:
+            json.loads(self.vwhat.outputs.stdout, encoding='utf-8')
+        except ValueError:
+            self.fail(msg="No JSON object could be decoded:\n" + self.vwhat.outputs.stdout)
+
+
+if __name__ == '__main__':
+    test()


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

Added: grass/branches/releasebranch_7_0/vector/v.what/testsuite/test_vwhat_ncspm.py
===================================================================
--- grass/branches/releasebranch_7_0/vector/v.what/testsuite/test_vwhat_ncspm.py	                        (rev 0)
+++ grass/branches/releasebranch_7_0/vector/v.what/testsuite/test_vwhat_ncspm.py	2015-01-01 22:36:28 UTC (rev 63923)
@@ -0,0 +1,262 @@
+# -*- coding: utf-8 -*-
+from grass.gunittest import TestCase, test
+from grass.gunittest.gmodules import SimpleModule
+
+
+out1 = """East: 636661
+North: 226489
+------------------------------------------------------------------
+Map: bridges 
+Mapset: PERMANENT
+Nothing found.
+------------------------------------------------------------------
+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: bridges 
+Mapset: PERMANENT
+Nothing found.
+------------------------------------------------------------------
+Map: roadsmajor 
+Mapset: PERMANENT
+Type: Line
+Id: 231
+Length: 2321.407296
+Layer: 1
+Category: 231
+
+Driver: ...
+Database: ...
+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: ...
+Database: ...
+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: ...
+Database: ...
+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=bridges
+Mapset=PERMANENT
+
+Map=roadsmajor
+Mapset=PERMANENT
+Type=Line
+Id=231
+Length=2321.407296
+Layer=1
+Category=231
+Driver=...
+Database=...
+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=...
+Database=...
+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=...
+Database=...
+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: bridges 
+Mapset: PERMANENT
+Nothing found.
+------------------------------------------------------------------
+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=['bridges', 'roadsmajor', 'precip_30ynormals_3d', 'lakes'],
+                                  layer=['-1', '-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.assertLooksLike(reference=out2, actual=self.vwhat.outputs.stdout)
+
+        self.vwhat.flags['g'].value = True
+        self.assertModule(self.vwhat)
+        self.assertLooksLike(reference=out3, actual=self.vwhat.outputs.stdout)
+
+    def test_threshold(self):
+        self.vwhat.inputs['distance'].value = 100
+        self.assertModule(self.vwhat)
+        self.assertLooksLike(reference=out4, actual=self.vwhat.outputs.stdout)
+
+    def test_print_options_json(self):
+        import json
+        self.vwhat.flags['j'].value = True
+        self.assertModule(self.vwhat)
+        try:
+            json.loads(self.vwhat.outputs.stdout)
+        except ValueError:
+            self.fail(msg="No JSON object could be decoded:\n" + self.vwhat.outputs.stdout)
+
+if __name__ == '__main__':
+    test()


Property changes on: grass/branches/releasebranch_7_0/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