[GRASS-SVN] r61232 - in grass/trunk: lib/python/gunittest lib/python/gunittest/testsuite temporal/t.rast.extract/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 10 08:57:13 PDT 2014


Author: wenzeslaus
Date: 2014-07-10 08:57:13 -0700 (Thu, 10 Jul 2014)
New Revision: 61232

Modified:
   grass/trunk/lib/python/gunittest/case.py
   grass/trunk/lib/python/gunittest/checkers.py
   grass/trunk/lib/python/gunittest/testsuite/test_assertions.py
   grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py
Log:
gunittest: rename assertCommandKeyValue to assertModuleKeyValue to be consistent with pygrass and rest of gunittest

Modified: grass/trunk/lib/python/gunittest/case.py
===================================================================
--- grass/trunk/lib/python/gunittest/case.py	2014-07-10 15:37:47 UTC (rev 61231)
+++ grass/trunk/lib/python/gunittest/case.py	2014-07-10 15:57:13 UTC (rev 61232)
@@ -4,7 +4,7 @@
 
 @brief GRASS Python testing framework test case
 
-(C) 2014 by the GRASS Development Team
+Copyright (C) 2014 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
@@ -147,22 +147,22 @@
     # TODO: auto-determine precision based on the map type
     # TODO: we can have also more general function without the subset reference
     # TODO: change name to Module
-    def assertCommandKeyValue(self, module, reference, sep,
-                              precision, msg=None, **parameters):
+    def assertModuleKeyValue(self, module, reference, sep,
+                             precision, msg=None, **parameters):
         """Test that output of a module is the same as provided subset.
 
         ::
 
-            self.assertCommandKeyValue('r.info', map='elevation', flags='gr',
-                                       reference=dict(min=55.58, max=156.33),
-                                       precision=0.01, sep='=')
+            self.assertModuleKeyValue('r.info', map='elevation', flags='gr',
+                                      reference=dict(min=55.58, max=156.33),
+                                      precision=0.01, sep='=')
 
         ::
 
             module = SimpleModule('r.info', map='elevation', flags='gr')
-            self.assertCommandKeyValue(module,
-                                       reference=dict(min=55.58, max=156.33),
-                                       precision=0.01, sep='=')
+            self.assertModuleKeyValue(module,
+                                      reference=dict(min=55.58, max=156.33),
+                                      precision=0.01, sep='=')
 
         The output of the module should be key-value pairs (shell script style)
         which is typically obtained using ``-g`` flag.
@@ -174,7 +174,7 @@
         raster_univar = text_to_keyvalue(module.outputs.stdout,
                                          sep=sep, skip_empty=True)
         if not keyvalue_equals(dict_a=reference, dict_b=raster_univar,
-                                a_is_subset=True, precision=precision):
+                               a_is_subset=True, precision=precision):
             unused, missing, mismatch = diff_keyvalue(dict_a=reference,
                                                       dict_b=raster_univar,
                                                       a_is_subset=True,
@@ -195,7 +195,7 @@
                 raise RuntimeError("keyvalue_equals() showed difference but"
                                    " diff_keyvalue() did not. This can be"
                                    " a bug in one of them or in the caller"
-                                   " (assertCommandKeyValue())")
+                                   " (assertModuleKeyValue())")
             self.fail(self._formatMessage(msg, stdMsg))
 
     def assertRasterFitsUnivar(self, raster, reference,
@@ -212,15 +212,15 @@
 
         Use keyword arguments syntax for all function parameters.
 
-        Does not -e (extended statistics) flag, use `assertCommandKeyValue()`
+        Does not -e (extended statistics) flag, use `assertModuleKeyValue()`
         for the full interface of arbitrary module.
         """
-        self.assertCommandKeyValue(module='r.univar',
-                                   map=raster,
-                                   separator='=',
-                                   flags='g',
-                                   reference=reference, msg=msg, sep='=',
-                                   precision=precision)
+        self.assertModuleKeyValue(module='r.univar',
+                                  map=raster,
+                                  separator='=',
+                                  flags='g',
+                                  reference=reference, msg=msg, sep='=',
+                                  precision=precision)
 
     def assertRasterFitsInfo(self, raster, reference,
                              precision=None, msg=None):
@@ -238,10 +238,10 @@
         This function supports values obtained -r (range) and
         -e (extended metadata) flags.
         """
-        self.assertCommandKeyValue(module='r.info',
-                                   map=raster, flags='gre',
-                                   reference=reference, msg=msg, sep='=',
-                                   precision=precision)
+        self.assertModuleKeyValue(module='r.info',
+                                  map=raster, flags='gre',
+                                  reference=reference, msg=msg, sep='=',
+                                  precision=precision)
 
     def assertVectorFitsUnivar(self, map, column, reference, msg=None,
                                layer=None, type=None, where=None,
@@ -259,7 +259,7 @@
         Use keyword arguments syntax for all function parameters.
 
         Does not support -d (geometry distances) flag, -e (extended statistics)
-        flag and few other, use `assertCommandKeyValue` for the full interface
+        flag and few other, use `assertModuleKeyValue` for the full interface
         of arbitrary module.
         """
         parameters = dict(map=map, column=column, flags='g')
@@ -269,10 +269,10 @@
             parameters.update(type=type)
         if where:
             parameters.update(where=where)
-        self.assertCommandKeyValue(module='v.univar',
-                                   reference=reference, msg=msg, sep='=',
-                                   precision=precision,
-                                   **parameters)
+        self.assertModuleKeyValue(module='v.univar',
+                                  reference=reference, msg=msg, sep='=',
+                                  precision=precision,
+                                  **parameters)
 
     # TODO: use precision?
     # TODO: write a test for this method with r.in.ascii
@@ -402,9 +402,9 @@
             diff = self._compute_difference_raster(reference, actual,
                                                    'assertRastersNoDifference')
             try:
-                self.assertCommandKeyValue('r.info', map=diff, flags='r',
-                                           sep='=', precision=precision,
-                                           reference=statistics, msg=msg)
+                self.assertModuleKeyValue('r.info', map=diff, flags='r',
+                                          sep='=', precision=precision,
+                                          reference=statistics, msg=msg)
             finally:
                 call_module('g.remove', rast=diff)
         # general case
@@ -559,7 +559,7 @@
 
 
 # TODO: add tests and documentation to methods which are using this function
-# some test and documentation add to assertCommandKeyValue
+# some test and documentation add to assertModuleKeyValue
 def _module_from_parameters(module, **kwargs):
     if kwargs:
         if not isinstance(module, basestring):

Modified: grass/trunk/lib/python/gunittest/checkers.py
===================================================================
--- grass/trunk/lib/python/gunittest/checkers.py	2014-07-10 15:37:47 UTC (rev 61231)
+++ grass/trunk/lib/python/gunittest/checkers.py	2014-07-10 15:57:13 UTC (rev 61232)
@@ -4,7 +4,7 @@
 
 @brief GRASS Python testing framework checkers
 
-(C) 2014 by the GRASS Development Team
+Copyright (C) 2014 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.

Modified: grass/trunk/lib/python/gunittest/testsuite/test_assertions.py
===================================================================
--- grass/trunk/lib/python/gunittest/testsuite/test_assertions.py	2014-07-10 15:37:47 UTC (rev 61231)
+++ grass/trunk/lib/python/gunittest/testsuite/test_assertions.py	2014-07-10 15:57:13 UTC (rev 61232)
@@ -85,7 +85,7 @@
 
 
 class TestAssertCommandKeyValue(grass.gunittest.TestCase):
-    """Test usage of `.assertCommandKeyValue` method."""
+    """Test usage of `.assertModuleKeyValue` method."""
     # pylint: disable=R0904
 
     @classmethod
@@ -101,29 +101,29 @@
         """Test syntax with Module as module"""
         module = Module('r.info', map='elevation', flags='gr',
                         run_=False, finish_=False)
-        self.assertCommandKeyValue(module,
-                                   reference=dict(min=55.58, max=156.33),
-                                   precision=0.01, sep='=')
+        self.assertModuleKeyValue(module,
+                                  reference=dict(min=55.58, max=156.33),
+                                  precision=0.01, sep='=')
 
     def test_pygrass_simple_module(self):
         """Test syntax with SimpleModule as module"""
         module = SimpleModule('r.info', map='elevation', flags='gr')
-        self.assertCommandKeyValue(module,
-                                   reference=dict(min=55.58, max=156.33),
-                                   precision=0.01, sep='=')
+        self.assertModuleKeyValue(module,
+                                  reference=dict(min=55.58, max=156.33),
+                                  precision=0.01, sep='=')
 
     def test_direct_parameters(self):
         """Test syntax with module and its parameters as fnction parameters"""
-        self.assertCommandKeyValue('r.info', map='elevation', flags='gr',
-                                   reference=dict(min=55.58, max=156.33),
-                                   precision=0.01, sep='=')
+        self.assertModuleKeyValue('r.info', map='elevation', flags='gr',
+                                  reference=dict(min=55.58, max=156.33),
+                                  precision=0.01, sep='=')
 
     def test_parameters_parameter(self):
         """Test syntax with module parameters in one parameters dictionary"""
-        self.assertCommandKeyValue(module='r.info',
-                                   parameters=dict(map='elevation', flags='gr'),
-                                   reference=dict(min=55.58, max=156.33),
-                                   precision=0.01, sep='=')
+        self.assertModuleKeyValue(module='r.info',
+                                  parameters=dict(map='elevation', flags='gr'),
+                                  reference=dict(min=55.58, max=156.33),
+                                  precision=0.01, sep='=')
 
 
 class TestRasterMapAssertations(grass.gunittest.TestCase):

Modified: grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py
===================================================================
--- grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py	2014-07-10 15:37:47 UTC (rev 61231)
+++ grass/trunk/temporal/t.rast.extract/testsuite/test_extract.py	2014-07-10 15:57:13 UTC (rev 61232)
@@ -79,9 +79,9 @@
         max_min=300.0
         max_max=600.0"""
 
-        self.assertCommandKeyValue(module="t.info",  
-                                                        parameters=dict(flags="g",  input="precip_abs2"), 
-                                                        reference=tinfo_string,  precision=2,  sep="=")
+        self.assertModuleKeyValue(module="t.info",  
+                                  parameters=dict(flags="g", input="precip_abs2"), 
+                                  reference=tinfo_string, precision=2, sep="=")
 
     def test_selection_and_expression(self):
         """Perform a selection by datetime and a r.mapcalc expression"""
@@ -113,9 +113,9 @@
         max_min=500.0
         max_max=600.0"""
 
-        self.assertCommandKeyValue(module="t.info",  
-                                                        parameters=dict(flags="g",  input="precip_abs2"), 
-                                                        reference=tinfo_string,  precision=2,  sep="=")
+        self.assertModuleKeyValue(module="t.info",  
+                                  parameters=dict(flags="g", input="precip_abs2"), 
+                                  reference=tinfo_string, precision=2, sep="=")
 
     def test_expression_with_empty_maps(self):
         """Perform r.mapcalc expression and register empty maps"""
@@ -146,9 +146,9 @@
         max_min=500.0
         max_max=600.0"""
 
-        self.assertCommandKeyValue(module="t.info",  
-                                                        parameters=dict(flags="g",  input="precip_abs2"), 
-                                                        reference=tinfo_string,  precision=2,  sep="=")
+        self.assertModuleKeyValue(module="t.info",  
+                                  parameters=dict(flags="g", input="precip_abs2"), 
+                                  reference=tinfo_string, precision=2, sep="=")
 
 if __name__ == '__main__':
     from grass.gunittest.main import test



More information about the grass-commit mailing list