浏览代码

v.db.droptable: added test, thanks to Sanjeet Bhatti

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74242 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 6 年之前
父节点
当前提交
c753c9c53d
共有 1 个文件被更改,包括 48 次插入0 次删除
  1. 48 0
      scripts/v.db.droptable/testsuite/test_v_db_droptable.py

+ 48 - 0
scripts/v.db.droptable/testsuite/test_v_db_droptable.py

@@ -0,0 +1,48 @@
+"""
+Created on Sun Jun 09 09:18:39 2018
+
+@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 TestVDbDropTable(TestCase):
+    """Test v.db.droptable script"""
+
+    @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='myroads',
+                    flags='f')
+
+    def test_drop_table_check(self):
+        """Drop table check, the column should still be in the table"""
+        module = SimpleModule('v.db.droptable', map='myroads')
+        self.assertModule(module)
+
+        m = SimpleModule('db.tables', flags='p')
+        self.assertModule(m)
+        self.assertRegexpMatches(decode(m.outputs.stdout), 'myroads')
+
+    def test_drop_table_with_force(self):
+        """Drop table with force, the column should not be in the table"""
+        module = SimpleModule('v.db.droptable', map='myroads', flags='f')
+        self.assertModule(module)
+
+        m = SimpleModule('db.tables', flags='p')
+        self.assertModule(m)
+        self.assertNotRegexpMatches(decode(m.outputs.stdout), 'myroads')
+
+if __name__ == '__main__':
+    test()