test_v_db_update.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """
  2. Created on Sun Jun 08 22:14:26 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. class TestVDbUpdate(TestCase):
  10. """Test v.db.update script"""
  11. mapName = "mygeodetic_pts"
  12. @classmethod
  13. def setUpClass(cls):
  14. """Copy vect"""
  15. run_command("g.copy", vector="geodetic_pts,mygeodetic_pts")
  16. @classmethod
  17. def tearDownClass(cls):
  18. """Remove vector"""
  19. run_command("v.db.dropcolumn", map=cls.mapName, columns="zval")
  20. run_command("g.remove", flags="f", type="vector", name=cls.mapName)
  21. def test_update(self):
  22. """update value test"""
  23. run_command("v.db.addcolumn", map=self.mapName, column="zval double precision")
  24. module = SimpleModule(
  25. "v.db.update",
  26. map=self.mapName,
  27. column="zval",
  28. query_column="CAST(z_value AS double precision)",
  29. where="z_value <> 'N/A'",
  30. )
  31. self.assertModule(module)
  32. if __name__ == "__main__":
  33. test()