test_v_db_update.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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,
  24. column="zval double precision")
  25. module = SimpleModule('v.db.update', map=self.mapName, column='zval',
  26. query_column="CAST(z_value AS double precision)",
  27. where="z_value <> 'N/A'")
  28. self.assertModule(module)
  29. if __name__ == '__main__':
  30. test()