Parcourir la source

pygrass library: Make use of the gunittst framework methods for module calls. The region class can now set the computational raster region of a process.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66060 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert il y a 9 ans
Parent
commit
4d7634fd8c

+ 13 - 1
lib/python/pygrass/gis/region.py

@@ -305,7 +305,8 @@ class Region(object):
         ..
         """
         attrs = ['north', 'south', 'west', 'east', 'top', 'bottom',
-                 'nsres', 'ewres', 'tbres']
+                 'nsres', 'ewres', 'tbres', 'rows', 'cols', 'cells',
+                 'zone', 'proj']
         for attr in attrs:
             if getattr(self, attr) != getattr(reg, attr):
                 return False
@@ -422,6 +423,17 @@ class Region(object):
             libraster.Rast_get_cellhd(raster_name, mapset,
                                       self.byref())
 
+    def set_raster_region(self):
+        """Set the computational region (window) for all raster maps in the current process.
+           
+           Attention: All raster objects must be closed or the
+                      process will be terminated.
+                      
+           The Raster library C function Rast_set_window() is called.
+        
+        """
+        libraster.Rast_set_window(self.byref())
+
     def get_current(self):
         """Get the current working region of this process
            and store it into this Region object

+ 5 - 0
lib/python/pygrass/utils.py

@@ -419,6 +419,11 @@ def create_test_vector_map(map_name="test_vector"):
         vect.comment = 'This is a comment'
 
         vect.table.conn.commit()
+        
+        vect.organization = "Thuenen Institut"
+        vect.person = "Soeren Gebbert"
+        vect.title = "Test dataset"
+        vect.comment = "This is a comment"
         vect.close()
 
 def create_test_stream_network_map(map_name="streams"):

+ 6 - 12
lib/python/pygrass/vector/testsuite/test_geometry.py

@@ -121,10 +121,8 @@ class LineTestCase(TestCase):
             cls.c_mapinfo = None
 
         """Remove the generated vector map, if exist"""
-        from grass.pygrass.utils import get_mapset_vector
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
     def test_len(self):
         """Test __len__ magic method"""
@@ -214,10 +212,8 @@ class NodeTestCase(TestCase):
             cls.c_mapinfo = None
 
         """Remove the generated vector map, if exist"""
-        from grass.pygrass.utils import get_mapset_vector
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
     def test_init(self):
         """Test Node __init__"""
@@ -270,10 +266,8 @@ class AreaTestCase(TestCase):
             cls.c_mapinfo = None
 
         """Remove the generated vector map, if exist"""
-        from grass.pygrass.utils import get_mapset_vector
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
     def test_init(self):
         """Test area __init__ and basic functions"""

+ 3 - 4
lib/python/pygrass/vector/testsuite/test_vector.py

@@ -30,11 +30,10 @@ class VectorTopoTestCase(TestCase):
     def tearDownClass(cls):
         if cls.vect.is_open():
             cls.vect.close()
+
         """Remove the generated vector map, if exist"""
-        from grass.pygrass.utils import get_mapset_vector
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
     def test_getitem_slice(self):
         """Test that getitem handle correctly the slice starting from 1"""

+ 2 - 3
lib/python/pygrass/vector/testsuite/test_vector3d.py

@@ -60,9 +60,8 @@ class VectorTopo3DTestCase(TestCase):
     @classmethod
     def tearDownClass(cls):
         """Remove the generated vector map, if exist"""
-        mset = get_mapset_vector(cls.tmpname, mapset='')
-        if mset:
-            run_command("g.remove", flags='f', type='vector', name=cls.tmpname)
+        cls.runModule("g.remove", flags='f', type='vector', 
+                      name=cls.tmpname)
 
 
 if __name__ == '__main__':