test_v_db_addtable.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """
  2. Created on Sun Jun 09 12:01:34 2018
  3. @author: Sanjeet Bhatti
  4. """
  5. from grass.gunittest.case import TestCase
  6. from grass.gunittest.main import test
  7. from grass.gunittest.gmodules import SimpleModule
  8. from grass.script.core import run_command
  9. from grass.script.utils import decode
  10. class TestVDbAddTable(TestCase):
  11. """Test v.db.addtable script"""
  12. @classmethod
  13. def setUpClass(cls):
  14. """Copy vector."""
  15. run_command("g.copy", vector="roadsmajor,myroads")
  16. @classmethod
  17. def tearDownClass(cls):
  18. """Remove copied vector"""
  19. run_command("g.remove", type="vector", name="myroads", flags="f")
  20. def test_add_single_columned_table_check(self):
  21. """Add a new attribute table with single column to layer 2"""
  22. module = SimpleModule(
  23. "v.db.addtable", map="myroads", columns="slope double precision", layer=2
  24. )
  25. self.assertModule(module)
  26. run_command("v.db.connect", flags="p", map="myroads")
  27. m = SimpleModule("v.info", map="myroads", flags="c")
  28. self.assertModule(m)
  29. self.assertNotRegexpMatches(decode(m.outputs.stdout), "slope")
  30. m = SimpleModule("v.info", map="myroads", flags="c", layer=2)
  31. self.assertModule(m)
  32. self.assertRegexpMatches(decode(m.outputs.stdout), "slope")
  33. if __name__ == "__main__":
  34. test()