[GRASS-SVN] r65443 - grass/trunk/vector/v.in.ascii/testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jun 11 14:55:16 PDT 2015
Author: wenzeslaus
Date: 2015-06-11 14:55:16 -0700 (Thu, 11 Jun 2015)
New Revision: 65443
Modified:
grass/trunk/vector/v.in.ascii/testsuite/test_csv.py
Log:
v.in.ascii: add test case with field delimeter in text field (extends r65427)
Modified: grass/trunk/vector/v.in.ascii/testsuite/test_csv.py
===================================================================
--- grass/trunk/vector/v.in.ascii/testsuite/test_csv.py 2015-06-11 19:59:17 UTC (rev 65442)
+++ grass/trunk/vector/v.in.ascii/testsuite/test_csv.py 2015-06-11 21:55:16 UTC (rev 65443)
@@ -75,7 +75,7 @@
msg="Attribute table has wrong entries")
def test_text_delimeter(self):
- """Test loading CSV with delimiter
+ """Test loading CSV with text delimiter
Text delimiter added in r63581
"""
@@ -132,5 +132,51 @@
msg="Attribute table has wrong entries")
+INPUT_DELIM_IN_TEXT = """Id,POINT_X,POINT_Y,Category,"ED field estimate"
+100,437343.6704,4061363.41525,"High Erosion, Low Canopy","Low Deposition, Low Canopy"
+101,453643.127906,4050070.29852,"High Erosion, High Canopy","Low Erosion, Low Canopy"
+102,454903.605427,4049480.80568,"High Erosion, High Canopy","High Erosion, Low Canopy"
+105,437734.838807,4060493.98315,"High Erosion, Low Canopy","Low Erosion, High Canopy"
+107,450833.019732,4048207.02664,"High Erosion, Low Canopy","Low Erosion, High Canopy"
+"""
+
+TABLE_2 = """cat|x|y|ed_cat|field_estimate
+100|437343.6704|4061363.41525|High Erosion, Low Canopy|Low Deposition, Low Canopy
+101|453643.127906|4050070.29852|High Erosion, High Canopy|Low Erosion, Low Canopy
+102|454903.605427|4049480.80568|High Erosion, High Canopy|High Erosion, Low Canopy
+105|437734.838807|4060493.98315|High Erosion, Low Canopy|Low Erosion, High Canopy
+107|450833.019732|4048207.02664|High Erosion, Low Canopy|Low Erosion, High Canopy
+"""
+
+
+class AdvancedCsvTestCase(TestCase):
+
+ xyvector = 'yxvetor_test'
+
+ def tearDown(self):
+ """Remove the vector map after each test method"""
+ self.runModule('g.remove', flags='f', type='vector',
+ name=self.xyvector)
+
+ def test_delimeter_in_text(self):
+ """Test loading CSV with delimiter in text
+
+ Text delimiter added in r63581
+ """
+ self.assertModule(
+ 'v.in.ascii', input='-', output=self.xyvector,
+ separator='comma', text='doublequote',
+ skip=1, x=2, y=3, cat=1,
+ columns="cat int, x double, y double,"
+ " ed_cat varchar(40), field_estimate varchar(40)",
+ stdin_=INPUT_DELIM_IN_TEXT)
+
+ category = read_command('v.db.select', map=self.xyvector,
+ separator='pipe')
+ self.assertEqual(first=TABLE_2.replace('\n', os.linesep),
+ second=category,
+ msg="Attribute table has wrong entries")
+
+
if __name__ == '__main__':
test()
More information about the grass-commit
mailing list