[GRASS-SVN] r74257 - in grass/trunk/scripts/db.dropcolumn: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 13 12:57:43 PDT 2019
Author: lucadelu
Date: 2019-03-13 12:57:43 -0700 (Wed, 13 Mar 2019)
New Revision: 74257
Added:
grass/trunk/scripts/db.dropcolumn/testsuite/
grass/trunk/scripts/db.dropcolumn/testsuite/test_db_dropcolumn.py
Log:
db.dropcolumn: added test, thanks to Sanjeet Bhatti
Added: grass/trunk/scripts/db.dropcolumn/testsuite/test_db_dropcolumn.py
===================================================================
--- grass/trunk/scripts/db.dropcolumn/testsuite/test_db_dropcolumn.py (rev 0)
+++ grass/trunk/scripts/db.dropcolumn/testsuite/test_db_dropcolumn.py 2019-03-13 19:57:43 UTC (rev 74257)
@@ -0,0 +1,54 @@
+"""
+Created on Sun Jun 07 19:08:34 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
+
+
+class TestDbDropColumn(TestCase):
+ """Test db.dropcolumn script"""
+
+ mapName = 'myroads'
+ colName = 'SHAPE_LEN'
+
+ @classmethod
+ def setUpClass(cls):
+ """Copy vector."""
+ run_command('g.copy', vector='roadsmajor,myroads')
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove copied vector"""
+ run_command('g.remove', type='vector', name=cls.mapName,
+ flags='f')
+
+ def test_drop_column_check(self):
+ """Drop column check, the column should still be in the table"""
+ module = SimpleModule('db.dropcolumn', table=self.mapName,
+ column=self.colName)
+ self.assertModule(module)
+
+ m = SimpleModule('db.columns', table=self.mapName)
+ self.assertModule(m)
+ self.assertRegexpMatches(decode(m.outputs.stdout), self.colName)
+
+ def test_drop_column_with_force(self):
+ """Drop column with force, the column should not be in the table"""
+ module = SimpleModule('db.dropcolumn', table=self.mapName,
+ column=self.colName,
+ flags='f')
+ self.assertModule(module)
+
+ m = SimpleModule('db.columns', table=self.mapName)
+ self.assertModule(m)
+ self.assertNotRegexpMatches(decode(m.outputs.stdout), self.colName)
+
+if __name__ == '__main__':
+ test()
Property changes on: grass/trunk/scripts/db.dropcolumn/testsuite/test_db_dropcolumn.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