[GRASS-SVN] r71733 - in grass/trunk/db/db.copy: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Nov 14 05:11:01 PST 2017


Author: lucadelu
Date: 2017-11-14 05:11:01 -0800 (Tue, 14 Nov 2017)
New Revision: 71733

Added:
   grass/trunk/db/db.copy/testsuite/
   grass/trunk/db/db.copy/testsuite/test_dbcopy.py
Log:
db.copy: added tests

Added: grass/trunk/db/db.copy/testsuite/test_dbcopy.py
===================================================================
--- grass/trunk/db/db.copy/testsuite/test_dbcopy.py	                        (rev 0)
+++ grass/trunk/db/db.copy/testsuite/test_dbcopy.py	2017-11-14 13:11:01 UTC (rev 71733)
@@ -0,0 +1,44 @@
+from grass.gunittest.case import TestCase
+from grass.gunittest.main import test
+from grass.script.core import read_command
+
+
+class TestDbCopy(TestCase):
+    invect = 'zipcodes'
+    orig_mapset = '$GISDBASE/$LOCATION_NAME/PERMANENT/sqlite/sqlite.db'
+    outable = 'my_' + invect
+
+    @classmethod
+    def tearDownClass(cls):
+        cls.runModule('db.droptable', table=cls.outable, flags='f',
+                      database='$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db')
+
+    def test_fromtable(self):
+        self.runModule('db.copy', from_database=self.orig_mapset, 
+                       from_table=self.invect, to_table=self.outable,
+                       overwrite=True)
+        orig = read_command('db.select', table=self.invect,
+                            database=self.orig_mapset)
+        new = read_command('db.select', table=self.outable)
+        self.assertEqual(first=orig, second=new)
+
+    def test_select(self):
+        self.runModule('db.copy', from_database=self.orig_mapset,
+                       to_table=self.outable, overwrite=True,
+                       select="SELECT * from {inp} WHERE NAME='RALEIGH'".format(inp=self.invect))
+        orig = read_command('db.select', database=self.orig_mapset,
+                            sql="SELECT * from {inp} WHERE NAME='RALEIGH'".format(inp=self.invect))
+        new = read_command('db.select', table=self.outable)
+        self.assertEqual(first=orig, second=new)
+
+    def test_where(self):
+        self.runModule('db.copy', from_database=self.orig_mapset,
+                       to_table=self.outable, overwrite=True,
+                       from_table=self.invect, where="NAME='RALEIGH'")
+        orig = read_command('db.select', database=self.orig_mapset,
+                            sql="SELECT * from {inp} WHERE NAME='RALEIGH'".format(inp=self.invect))
+        new = read_command('db.select', table=self.outable)
+        self.assertEqual(first=orig, second=new)
+
+if __name__ == '__main__':
+    test()


Property changes on: grass/trunk/db/db.copy/testsuite/test_dbcopy.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list