[GRASS-SVN] r55556 - in grass-addons/grass7/raster/r.agent: libagent tests

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 27 08:29:24 PDT 2013


Author: mic
Date: 2013-03-27 08:29:23 -0700 (Wed, 27 Mar 2013)
New Revision: 55556

Modified:
   grass-addons/grass7/raster/r.agent/libagent/grassland.py
   grass-addons/grass7/raster/r.agent/tests/test_grassland.py
Log:
throw error on missing maps and reorganize test

Modified: grass-addons/grass7/raster/r.agent/libagent/grassland.py
===================================================================
--- grass-addons/grass7/raster/r.agent/libagent/grassland.py	2013-03-27 15:18:58 UTC (rev 55555)
+++ grass-addons/grass7/raster/r.agent/libagent/grassland.py	2013-03-27 15:29:23 UTC (rev 55556)
@@ -9,7 +9,7 @@
               for details.
 """
 
-import playground
+import error, playground
 import grass.script as grass
 from grass.script import array as garray
 
@@ -38,6 +38,9 @@
             layer.read(grassmapname)
             self.grassmapnames[layername] = grassmapname
             self.setlayer(layername, layer, force)
+        else:
+            raise error.DataError("r.agent::libagent.grassland.Grassland()",
+                                    "Grass Map was missing.")
 
     def createlayer(self, layername, grassmapname=False, force=False):
         """

Modified: grass-addons/grass7/raster/r.agent/tests/test_grassland.py
===================================================================
--- grass-addons/grass7/raster/r.agent/tests/test_grassland.py	2013-03-27 15:18:58 UTC (rev 55555)
+++ grass-addons/grass7/raster/r.agent/tests/test_grassland.py	2013-03-27 15:29:23 UTC (rev 55556)
@@ -68,16 +68,23 @@
         if self.rastlayername:
             layer = garray.array()
             # set the layer
-            self.pg.setgrasslayer(self.rastlayername, self.rastlayername)
-            # test if it fails the second time
-            self.assertRaises(error.Error, self.pg.setgrasslayer,
+            ## the first time it is missing
+            self.assertRaises(error.DataError, self.pg.setgrasslayer,
                                     *[self.rastlayername, self.rastlayername])
-            if not ( self.pg.layers.has_key(self.rastlayername) and \
-                        self.pg.grassmapnames.has_key(self.rastlayername) ):
-                print "GRASS map layer was set but seems missing"
-                self.assertTrue(False)
+            ## so we need to write it first
+            pass
+#TODO
+            ## the second time it should be added correctly
+
+            ## now test whether it fails the third time
+#            self.assertRaises(error.Error, self.pg.setgrasslayer,
+#                                    *[self.rastlayername, self.rastlayername])
+#            if not ( self.pg.layers.has_key(self.rastlayername) and \
+#                        self.pg.grassmapnames.has_key(self.rastlayername) ):
+#                print "GRASS map layer was set but seems missing"
+#                self.assertTrue(False)
             # set it once more, this time forcing it
-            self.pg.setgrasslayer(self.rastlayername, self.rastlayername, True)
+#            self.pg.setgrasslayer(self.rastlayername, self.rastlayername, True)
 
     def test_createlayer(self):
         self.pg.createlayer("foo", "foo")



More information about the grass-commit mailing list