[GRASS-SVN] r74259 - in grass/trunk/scripts/db.in.ogr: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 13 13:00:45 PDT 2019


Author: lucadelu
Date: 2019-03-13 13:00:45 -0700 (Wed, 13 Mar 2019)
New Revision: 74259

Added:
   grass/trunk/scripts/db.in.ogr/testsuite/
   grass/trunk/scripts/db.in.ogr/testsuite/test_db_in_ogr.py
Log:
db.in.ogr: added test, thanks to Sanjeet Bhatti

Added: grass/trunk/scripts/db.in.ogr/testsuite/test_db_in_ogr.py
===================================================================
--- grass/trunk/scripts/db.in.ogr/testsuite/test_db_in_ogr.py	                        (rev 0)
+++ grass/trunk/scripts/db.in.ogr/testsuite/test_db_in_ogr.py	2019-03-13 20:00:45 UTC (rev 74259)
@@ -0,0 +1,63 @@
+"""
+Created on Sun Jun 07 20:14:04 2018
+
+ at author: Sanjeet Bhatti
+"""
+
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+from grass.gunittest.gmodules import SimpleModule
+
+from grass.script.core import run_command
+from grass.script.utils import decode
+
+import os
+
+
+class TestDbInOgr(TestCase):
+    """Test db.in.ogr script"""
+
+    csvFile = 'sample_data.csv'
+    dbfFile = 'sample_data.dbf'
+    tableName1 = 'sample_table1'
+    tableName2 = 'sample_table2'
+
+    @classmethod
+    def setUpClass(cls):
+        """Create temporary files. Remove if the tables already exists."""
+        cls.runModule('db.out.ogr', input='geology', output=cls.csvFile)
+        cls.runModule('db.out.ogr', input='geology', output=cls.dbfFile,
+                      format='DBF')
+        cls.runModule('db.droptable', table=cls.tableName1, flags='f')
+        cls.runModule('db.droptable', table=cls.tableName2, flags='f')
+
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the created files and the created table"""
+        os.remove(cls.csvFile)
+        os.remove(cls.dbfFile)
+        cls.runModule('db.droptable', table=cls.tableName1, flags='f')
+        cls.runModule('db.droptable', table=cls.tableName2, flags='f')
+
+    def test_import_csv_file(self):
+        """import csv table"""
+        module = SimpleModule('db.in.ogr', input=self.csvFile,
+                              output=self.tableName1)
+        self.assertModule(module)
+
+        m = SimpleModule('db.tables', flags='p')
+        self.assertModule(m)
+        self.assertRegexpMatches(decode(m.outputs.stdout), self.tableName1)
+
+    def test_import_dbf_file(self):
+        """import dbf table"""
+        module = SimpleModule('db.in.ogr', input=self.dbfFile,
+                              output=self.tableName2)
+        self.assertModule(module)
+
+        m = SimpleModule('db.tables', flags='p')
+        self.assertModule(m)
+        self.assertRegexpMatches(decode(m.outputs.stdout), self.tableName2)
+
+if __name__ == '__main__':
+    test()


Property changes on: grass/trunk/scripts/db.in.ogr/testsuite/test_db_in_ogr.py
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-python
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property


More information about the grass-commit mailing list