[GRASS-SVN] r62011 - in grass/trunk/general: g.list g.list/testsuite g.remove g.remove/testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 17 06:53:13 PDT 2014
Author: hcho
Date: 2014-09-17 06:53:13 -0700 (Wed, 17 Sep 2014)
New Revision: 62011
Added:
grass/trunk/general/g.list/g.list.html
grass/trunk/general/g.list/testsuite/test_g_list.py
grass/trunk/general/g.remove/g.remove.html
grass/trunk/general/g.remove/testsuite/test_g_remove.py
Removed:
grass/trunk/general/g.list/g.mlist.html
grass/trunk/general/g.list/testsuite/test_g_mlist.py
grass/trunk/general/g.remove/g.mremove.html
grass/trunk/general/g.remove/testsuite/test_g_mremove.py
Modified:
grass/trunk/general/g.list/Makefile
grass/trunk/general/g.list/main.c
grass/trunk/general/g.remove/Makefile
grass/trunk/general/g.remove/main.c
Log:
Replace g.list/g.remove with g.mlist/g.mremove
Modified: grass/trunk/general/g.list/Makefile
===================================================================
--- grass/trunk/general/g.list/Makefile 2014-09-17 13:46:24 UTC (rev 62010)
+++ grass/trunk/general/g.list/Makefile 2014-09-17 13:53:13 UTC (rev 62011)
@@ -1,6 +1,6 @@
MODULE_TOPDIR = ../..
-PGM = g.mlist
+PGM = g.list
LIBES = $(MANAGELIB) $(GISLIB) $(RASTERLIB) $(RASTER3DLIB) $(VECTORLIB)
DEPENDENCIES = $(MANAGEDEP) $(GISDEP) $(RASTERDEP) $(RASTER3DDEP) $(VECTORDEP)
Copied: grass/trunk/general/g.list/g.list.html (from rev 62010, grass/trunk/general/g.list/g.mlist.html)
===================================================================
--- grass/trunk/general/g.list/g.list.html (rev 0)
+++ grass/trunk/general/g.list/g.list.html 2014-09-17 13:53:13 UTC (rev 62011)
@@ -0,0 +1,186 @@
+<h2>DESCRIPTION</h2>
+
+<em>g.list</em> searches for data files matching a pattern given by
+wildcards or POSIX Extended Regular Expressions.
+
+<h2>NOTES</h2>
+
+The output of <em>g.list</em> may be useful for other programs' parameter
+input (e.g. time series for <em><a href="r.series.html">r.series</a></em>)
+when used with <em>separator=comma</em>.
+
+<h2>EXAMPLES</h2>
+
+List all available GRASS data base files:
+<div class="code"><pre>
+g.list type=all
+</pre></div>
+
+List all raster and vector maps:
+<div class="code"><pre>
+g.list type=rast,vect
+</pre></div>
+
+<h3>Mapset search path</h3>
+
+If <b>mapset</b> is not specified than <em>g.list</em> searches for
+data files in the mapsets which are included in the search path
+(defined by <em><a href="g.mapsets.html">g.mapsets</a></em>),
+see <tt>g.mapsets -p</tt>.
+
+<div class="code"><pre>
+g.list rast
+
+raster map(s) available in mapset <user1>:
+dmt
+...
+raster map(s) available in mapset <PERMANENT>:
+aspect
+...
+</pre></div>
+
+By option <b>mapset</b>=. (one dot) can be listed only data files from
+the current mapset:
+
+<div class="code"><pre>
+g.list rast mapset=.
+raster map(s) available in mapset <user1>:
+dmt
+</pre></div>
+
+Similarly <b>mapset</b>=* (one asterisk) prints data files from all
+available mapsets also including those which are not listed in the
+current search path (see <tt>g.mapsets -l</tt>).
+
+<div class="code"><pre>
+g.list rast mapset=*
+
+raster map(s) available in mapset <landsat>:
+lsat5_1987_10
+...
+raster map(s) available in mapset <user1>:
+dmt
+...
+raster map(s) available in mapset <PERMANENT>:
+aspect
+...
+</pre></div>
+
+<h3>Wildcards</h3>
+
+List all vector maps starting with letter "r":
+<div class="code"><pre>
+g.list type=vect pattern="r*"
+</pre></div>
+
+List all vector maps starting with letter "r" or "a":
+<div class="code"><pre>
+g.list type=vect pattern="[ra]*"
+</pre></div>
+
+List all raster maps starting with "soil_" or "landuse_":
+<div class="code"><pre>
+g.list type=rast pattern="{soil,landuse}_*"
+</pre></div>
+
+List certain raster maps with one variable character/number:
+<div class="code"><pre>
+g.list type=rast pattern="N45E00?.meters"
+</pre></div>
+
+Use of <b>exclude</b> parameter:
+<div class="code"><pre>
+# without exclude:
+ g.list rast pat="r*" mapset=PERMANENT
+ railroads
+ roads
+ rstrct.areas
+ rushmore
+
+# exclude only complete word(s):
+ g.list rast pat="r*" exclude=roads mapset=PERMANENT
+ railroads
+ rstrct.areas
+ rushmore
+
+# exclude with wildcard:
+ g.list rast pat="r*" exclude="*roads*" mapset=PERMANENT
+ rstrct.areas
+ rushmore
+</pre></div>
+
+<h3>Regular expressions</h3>
+
+List all soil maps starting with "soils" in their name:
+<div class="code"><pre>
+g.list -r type=rast pattern='^soils'
+</pre></div>
+
+List "tmp" if "tmp" raster map exists:
+<div class="code"><pre>
+g.list -r type=rast pattern='^tmp$'
+</pre></div>
+
+List "tmp0" ..."tmp9" if corresponding vector map exists
+(each map name linewise):
+<div class="code"><pre>
+g.list -r type=vect pattern='^tmp[0-9]$'
+</pre></div>
+
+List "tmp0"..."tmp9" if corresponding vector map exists
+(each map name comma separated):
+<div class="code"><pre>
+g.list -r type=vect separator=comma pattern='^tmp[0-9]$'
+</pre></div>
+
+<h3>Extended regular expressions</h3>
+
+List all precipitation maps for the years 1997-2012, comma separated:
+<div class="code"><pre>
+g.list -e type=rast separator=comma pattern="precip_total.(199[7-9]|200[0-9]|201[0-2]).sum"
+</pre></div>
+
+<h3>Maps whose region overlaps with a saved region</h3>
+
+List all raster maps starting with "tmp_" whose region overlaps with
+the region of "test" raster map:
+<div class="code"><pre>
+g.region rast=test save=test_region
+g.list type=rast pattern='tmp_*' region=test_region
+</pre></div>
+
+List "tmp0"..."tmp9" vector maps whose region overlaps with
+the current region:
+<div class="code"><pre>
+g.list -r type=vect pattern='^tmp[0-9]$' region=.
+</pre></div>
+
+List all raster and vector maps whose region overlaps with the default region
+of the PERMANENT mapset in the current location (DEFAULT_WIND):
+<div class="code"><pre>
+g.list type=rast,vect region=*
+</pre></div>
+
+Note that, without <tt>region=*</tt>, <tt>g.list type=rast,vect</tt> simply
+lists all available raster and vector maps from the current search path
+regardless of their region.
+
+<h2>SEE ALSO</h2>
+
+<em>
+<a href="r.series.html">r.series</a>,
+<a href="t.list.html">t.list</a>,
+<a href="t.rast.list.html">t.rast.list</a>,
+<a href="t.vect.list.html">t.vect.list</a>
+</em>
+<p>
+<a href="http://en.wikipedia.org/wiki/Regular_expression">Regular expressions</a>
+(aka regex) - from Wikipedia, the free encyclopedia
+
+<h2>AUTHOR</h2>
+
+Huidae Cho<br>
+grass4u at gmail.com
+
+<p>
+<i>Last changed: $Date$</i>
Deleted: grass/trunk/general/g.list/g.mlist.html
===================================================================
--- grass/trunk/general/g.list/g.mlist.html 2014-09-17 13:46:24 UTC (rev 62010)
+++ grass/trunk/general/g.list/g.mlist.html 2014-09-17 13:53:13 UTC (rev 62011)
@@ -1,192 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>g.mlist</em> searches for data files matching a pattern given by
-wildcards or POSIX Extended Regular Expressions. It is an extended
-version of <em><a href="g.list.html">g.list</a></em>.
-
-<p>
-See also the <em><a href="g.list.html">g.list</a></em> help page for
-discussion of some module options.
-
-<h2>NOTES</h2>
-
-The output of <em>g.mlist</em> may be useful for other programs' parameter
-input (e.g. time series for <em><a href="r.series.html">r.series</a></em>)
-when used with <em>separator=comma</em>.
-
-<h2>EXAMPLES</h2>
-
-List all available GRASS data base files:
-<div class="code"><pre>
-g.mlist type=all
-</pre></div>
-
-List all raster and vector maps:
-<div class="code"><pre>
-g.mlist type=rast,vect
-</pre></div>
-
-<h3>Mapset search path</h3>
-
-If <b>mapset</b> is not specified than <em>g.mlist</em> searches for
-data files in the mapsets which are included in the search path
-(defined by <em><a href="g.mapsets.html">g.mapsets</a></em>),
-see <tt>g.mapsets -p</tt>.
-
-<div class="code"><pre>
-g.mlist rast
-
-raster map(s) available in mapset <user1>:
-dmt
-...
-raster map(s) available in mapset <PERMANENT>:
-aspect
-...
-</pre></div>
-
-By option <b>mapset</b>=. (one dot) can be listed only data files from
-the current mapset:
-
-<div class="code"><pre>
-g.mlist rast mapset=.
-raster map(s) available in mapset <user1>:
-dmt
-</pre></div>
-
-Similarly <b>mapset</b>=* (one asterisk) prints data files from all
-available mapsets also including those which are not listed in the
-current search path (see <tt>g.mapsets -l</tt>).
-
-<div class="code"><pre>
-g.mlist rast mapset=*
-
-raster map(s) available in mapset <landsat>:
-lsat5_1987_10
-...
-raster map(s) available in mapset <user1>:
-dmt
-...
-raster map(s) available in mapset <PERMANENT>:
-aspect
-...
-</pre></div>
-
-<h3>Wildcards</h3>
-
-List all vector maps starting with letter "r":
-<div class="code"><pre>
-g.mlist type=vect pattern="r*"
-</pre></div>
-
-List all vector maps starting with letter "r" or "a":
-<div class="code"><pre>
-g.mlist type=vect pattern="[ra]*"
-</pre></div>
-
-List all raster maps starting with "soil_" or "landuse_":
-<div class="code"><pre>
-g.mlist type=rast pattern="{soil,landuse}_*"
-</pre></div>
-
-List certain raster maps with one variable character/number:
-<div class="code"><pre>
-g.mlist type=rast pattern="N45E00?.meters"
-</pre></div>
-
-Use of <b>exclude</b> parameter:
-<div class="code"><pre>
-# without exclude:
- g.mlist rast pat="r*" mapset=PERMANENT
- railroads
- roads
- rstrct.areas
- rushmore
-
-# exclude only complete word(s):
- g.mlist rast pat="r*" exclude=roads mapset=PERMANENT
- railroads
- rstrct.areas
- rushmore
-
-# exclude with wildcard:
- g.mlist rast pat="r*" exclude="*roads*" mapset=PERMANENT
- rstrct.areas
- rushmore
-</pre></div>
-
-<h3>Regular expressions</h3>
-
-List all soil maps starting with "soils" in their name:
-<div class="code"><pre>
-g.mlist -r type=rast pattern='^soils'
-</pre></div>
-
-List "tmp" if "tmp" raster map exists:
-<div class="code"><pre>
-g.mlist -r type=rast pattern='^tmp$'
-</pre></div>
-
-List "tmp0" ..."tmp9" if corresponding vector map exists
-(each map name linewise):
-<div class="code"><pre>
-g.mlist -r type=vect pattern='^tmp[0-9]$'
-</pre></div>
-
-List "tmp0"..."tmp9" if corresponding vector map exists
-(each map name comma separated):
-<div class="code"><pre>
-g.mlist -r type=vect separator=comma pattern='^tmp[0-9]$'
-</pre></div>
-
-<h3>Extended regular expressions</h3>
-
-List all precipitation maps for the years 1997-2012, comma separated:
-<div class="code"><pre>
-g.mlist -e type=rast separator=comma pattern="precip_total.(199[7-9]|200[0-9]|201[0-2]).sum"
-</pre></div>
-
-<h3>Maps whose region overlaps with a saved region</h3>
-
-List all raster maps starting with "tmp_" whose region overlaps with
-the region of "test" raster map:
-<div class="code"><pre>
-g.region rast=test save=test_region
-g.mlist type=rast pattern='tmp_*' region=test_region
-</pre></div>
-
-List "tmp0"..."tmp9" vector maps whose region overlaps with
-the current region:
-<div class="code"><pre>
-g.mlist -r type=vect pattern='^tmp[0-9]$' region=.
-</pre></div>
-
-List all raster and vector maps whose region overlaps with the default region
-of the PERMANENT mapset in the current location (DEFAULT_WIND):
-<div class="code"><pre>
-g.mlist type=rast,vect region=*
-</pre></div>
-
-Note that, without <tt>region=*</tt>, <tt>g.mlist type=rast,vect</tt> simply
-lists all available raster and vector maps from the current search path
-regardless of their region.
-
-<h2>SEE ALSO</h2>
-
-<em>
-<a href="g.list.html">g.list</a>,
-<a href="r.series.html">r.series</a>,
-<a href="t.list.html">t.list</a>,
-<a href="t.rast.list.html">t.rast.list</a>,
-<a href="t.vect.list.html">t.vect.list</a>
-</em>
-<p>
-<a href="http://en.wikipedia.org/wiki/Regular_expression">Regular expressions</a>
-(aka regex) - from Wikipedia, the free encyclopedia
-
-<h2>AUTHOR</h2>
-
-Huidae Cho<br>
-grass4u at gmail.com
-
-<p>
-<i>Last changed: $Date$</i>
Modified: grass/trunk/general/g.list/main.c
===================================================================
--- grass/trunk/general/g.list/main.c 2014-09-17 13:46:24 UTC (rev 62010)
+++ grass/trunk/general/g.list/main.c 2014-09-17 13:53:13 UTC (rev 62011)
@@ -1,7 +1,7 @@
/****************************************************************************
*
- * MODULE: g.mlist
+ * MODULE: g.list
*
* AUTHOR(S): Huidae Cho
* Based on general/manage/cmd/list.c by Michael Shapiro.
Copied: grass/trunk/general/g.list/testsuite/test_g_list.py (from rev 62010, grass/trunk/general/g.list/testsuite/test_g_mlist.py)
===================================================================
--- grass/trunk/general/g.list/testsuite/test_g_list.py (rev 0)
+++ grass/trunk/general/g.list/testsuite/test_g_list.py 2014-09-17 13:53:13 UTC (rev 62011)
@@ -0,0 +1,55 @@
+"""g.list tests"""
+
+import grass.gunittest
+from grass.gunittest.gmodules import SimpleModule
+
+
+class GMlistWrongParamertersTest(grass.gunittest.TestCase):
+ """Test wrong input of parameters for g.list module"""
+
+ @classmethod
+ def setUpClass(cls):
+ """Create maps in a small region."""
+ cls.use_temp_region()
+ cls.runModule("g.region", s=0, n=5, w=0, e=5, res=1)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove temporary region"""
+ cls.del_temp_region()
+
+ def test_pt_flags(self):
+ """Test that -p and -t flags are exclusive"""
+ module = SimpleModule('g.list', flags='pt', type='rast')
+ self.assertModuleFail(module)
+ stderr = module.outputs.stderr
+ self.assertIn('-p', stderr)
+ self.assertIn('-t', stderr)
+
+ def test_ft_flags(self):
+ """Test that -f and -t flags are exclusive"""
+ module = SimpleModule('g.list', flags='ft', type='rast')
+ self.assertModuleFail(module)
+ stderr = module.outputs.stderr
+ self.assertIn('-f', stderr)
+ self.assertIn('-t', stderr)
+
+ def test_pf_flags(self):
+ """Test that -p and -f flags are exclusive"""
+ module = SimpleModule('g.list', flags='pf', type='rast')
+ self.assertModuleFail(module)
+ stderr = module.outputs.stderr
+ self.assertIn('-p', stderr)
+ self.assertIn('-f', stderr)
+
+ def test_re_flags(self):
+ """Test that -r and -e flags are exclusive"""
+ module = SimpleModule('g.list', flags='re', type='rast')
+ self.assertModuleFail(module)
+ stderr = module.outputs.stderr
+ self.assertIn('-r', stderr)
+ self.assertIn('-e', stderr)
+
+
+if __name__ == '__main__':
+ grass.gunittest.test()
Deleted: grass/trunk/general/g.list/testsuite/test_g_mlist.py
===================================================================
--- grass/trunk/general/g.list/testsuite/test_g_mlist.py 2014-09-17 13:46:24 UTC (rev 62010)
+++ grass/trunk/general/g.list/testsuite/test_g_mlist.py 2014-09-17 13:53:13 UTC (rev 62011)
@@ -1,55 +0,0 @@
-"""g.mlist tests"""
-
-import grass.gunittest
-from grass.gunittest.gmodules import SimpleModule
-
-
-class GMlistWrongParamertersTest(grass.gunittest.TestCase):
- """Test wrong input of parameters for g.mlist module"""
-
- @classmethod
- def setUpClass(cls):
- """Create maps in a small region."""
- cls.use_temp_region()
- cls.runModule("g.region", s=0, n=5, w=0, e=5, res=1)
-
- @classmethod
- def tearDownClass(cls):
- """Remove temporary region"""
- cls.del_temp_region()
-
- def test_pt_flags(self):
- """Test that -p and -t flags are exclusive"""
- module = SimpleModule('g.mlist', flags='pt', type='rast')
- self.assertModuleFail(module)
- stderr = module.outputs.stderr
- self.assertIn('-p', stderr)
- self.assertIn('-t', stderr)
-
- def test_ft_flags(self):
- """Test that -f and -t flags are exclusive"""
- module = SimpleModule('g.mlist', flags='ft', type='rast')
- self.assertModuleFail(module)
- stderr = module.outputs.stderr
- self.assertIn('-f', stderr)
- self.assertIn('-t', stderr)
-
- def test_pf_flags(self):
- """Test that -p and -f flags are exclusive"""
- module = SimpleModule('g.mlist', flags='pf', type='rast')
- self.assertModuleFail(module)
- stderr = module.outputs.stderr
- self.assertIn('-p', stderr)
- self.assertIn('-f', stderr)
-
- def test_re_flags(self):
- """Test that -r and -e flags are exclusive"""
- module = SimpleModule('g.mlist', flags='re', type='rast')
- self.assertModuleFail(module)
- stderr = module.outputs.stderr
- self.assertIn('-r', stderr)
- self.assertIn('-e', stderr)
-
-
-if __name__ == '__main__':
- grass.gunittest.test()
Modified: grass/trunk/general/g.remove/Makefile
===================================================================
--- grass/trunk/general/g.remove/Makefile 2014-09-17 13:46:24 UTC (rev 62010)
+++ grass/trunk/general/g.remove/Makefile 2014-09-17 13:53:13 UTC (rev 62011)
@@ -1,6 +1,6 @@
MODULE_TOPDIR = ../..
-PGM = g.mremove
+PGM = g.remove
LIBES = $(MANAGELIB) $(RASTERLIB) $(GISLIB)
DEPENDENCIES = $(MANAGEDEP) $(RASTERDEP) $(GISDEP)
Deleted: grass/trunk/general/g.remove/g.mremove.html
===================================================================
--- grass/trunk/general/g.remove/g.mremove.html 2014-09-17 13:46:24 UTC (rev 62010)
+++ grass/trunk/general/g.remove/g.mremove.html 2014-09-17 13:53:13 UTC (rev 62011)
@@ -1,38 +0,0 @@
-<h2>DESCRIPTION</h2>
-
-<em>g.mremove</em> removes data files matching a pattern given by wildcards or
-POSIX Extended Regular Expressions. If the <b>-f</b> force flag is not given
-then nothing is removed, instead the list of selected file names is printed to
-<tt>stdout</tt> as a preview of the files to be deleted.
-
-<h2>EXAMPLES</h2>
-
-Delete all raster maps starting with "<tt>tmp_</tt>" in the current mapset:
-
-<div class="code"><pre>
-# show matching raster maps but do not delete yet (as verification)
-g.mremove type=rast pattern="tmp_*"
-
-# actually delete the matching raster maps
-g.mremove -f type=rast pattern="tmp_*"
-</pre></div>
-
-Delete all raster maps starting with "<tt>stream_</tt>" in the current mapset,
-but exclude those ending with "<tt>_final</tt>":
-<div class="code"><pre>
-g.mremove -f type=rast pattern="stream_*" exclude="*_final"
-</pre></div>
-
-<h2>SEE ALSO</h2>
-
-<em>
-<a href="g.remove.html">g.remove</a>
-</em>
-
-<h2>AUTHOR</h2>
-
-Huidae Cho<br>
-grass4u at gmail.com
-
-<p>
-<i>Last changed: $Date$</i>
Copied: grass/trunk/general/g.remove/g.remove.html (from rev 62010, grass/trunk/general/g.remove/g.mremove.html)
===================================================================
--- grass/trunk/general/g.remove/g.remove.html (rev 0)
+++ grass/trunk/general/g.remove/g.remove.html 2014-09-17 13:53:13 UTC (rev 62011)
@@ -0,0 +1,37 @@
+<h2>DESCRIPTION</h2>
+
+<em>g.remove</em> removes data files matching a pattern given by wildcards or
+POSIX Extended Regular Expressions. If the <b>-f</b> force flag is not given
+then nothing is removed, instead the list of selected file names is printed to
+<tt>stdout</tt> as a preview of the files to be deleted.
+
+<h2>EXAMPLES</h2>
+
+Delete all raster maps starting with "<tt>tmp_</tt>" in the current mapset:
+
+<div class="code"><pre>
+# show matching raster maps but do not delete yet (as verification)
+g.remove type=rast pattern="tmp_*"
+
+# actually delete the matching raster maps
+g.remove -f type=rast pattern="tmp_*"
+</pre></div>
+
+Delete all raster maps starting with "<tt>stream_</tt>" in the current mapset,
+but exclude those ending with "<tt>_final</tt>":
+<div class="code"><pre>
+g.remove -f type=rast pattern="stream_*" exclude="*_final"
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em>
+</em>
+
+<h2>AUTHOR</h2>
+
+Huidae Cho<br>
+grass4u at gmail.com
+
+<p>
+<i>Last changed: $Date$</i>
Modified: grass/trunk/general/g.remove/main.c
===================================================================
--- grass/trunk/general/g.remove/main.c 2014-09-17 13:46:24 UTC (rev 62010)
+++ grass/trunk/general/g.remove/main.c 2014-09-17 13:53:13 UTC (rev 62011)
@@ -1,7 +1,7 @@
/****************************************************************************
*
- * MODULE: g.mremove
+ * MODULE: g.remove
*
* AUTHOR(S): Huidae Cho <grass4u gmail.com>
*
@@ -9,13 +9,12 @@
* CERL (original contributor),
* Radim Blazek <radim.blazek gmail.com>,
* Cedric Shock <cedricgrass shockfamily.net>,
- * Huidae Cho <grass4u gmail.com>,
* Glynn Clements <glynn gclements.plus.com>,
* Jachym Cepicky <jachym les-ejk.cz>,
* Markus Neteler <neteler itc.it>,
* Martin Landa <landa.martin gmail.com>
*
- * PURPOSE: lets users remove GRASS database files
+ * PURPOSE: Lets users remove GRASS database files
*
* COPYRIGHT: (C) 1999-2014 by the GRASS Development Team
*
Deleted: grass/trunk/general/g.remove/testsuite/test_g_mremove.py
===================================================================
--- grass/trunk/general/g.remove/testsuite/test_g_mremove.py 2014-09-17 13:46:24 UTC (rev 62010)
+++ grass/trunk/general/g.remove/testsuite/test_g_mremove.py 2014-09-17 13:53:13 UTC (rev 62011)
@@ -1,109 +0,0 @@
-"""Test of g.mremove module"""
-
-# TODO: rmapcalc probably fatals, replace or add raise on error?
-from grass.script.raster import mapcalc as rmapcalc
-
-import grass.gunittest
-from grass.gunittest.gutils import get_current_mapset
-from grass.gunittest.gmodules import SimpleModule
-
-# when used user1 must be replaced by current mapset
-REMOVE_RASTERS = """rast/test_map_0 at user1
-rast/test_map_1 at user1
-rast/test_map_2 at user1
-rast/test_map_3 at user1
-rast/test_map_4 at user1
-rast/test_map_5 at user1
-rast/test_map_6 at user1
-rast/test_map_7 at user1
-rast/test_map_8 at user1
-rast/test_map_9 at user1
-rast/test_two at user1
-"""
-
-REMOVING_RASTERS_LOG = """Removing raster <test_map_0>
-Removing raster <test_map_1>
-Removing raster <test_map_2>
-Removing raster <test_map_3>
-Removing raster <test_map_4>
-Removing raster <test_map_5>
-Removing raster <test_map_6>
-Removing raster <test_map_7>
-Removing raster <test_map_8>
-Removing raster <test_map_9>
-Removing raster <test_two>
-"""
-
-
-class GMRemoveTest(grass.gunittest.TestCase):
- """Test removing with g.mremove"""
-
- @classmethod
- def setUpClass(cls):
- """Set up small region for fast map creation."""
- cls.use_temp_region()
- cls.runModule("g.region", s=0, n=5, w=0, e=5, res=1)
-
- @classmethod
- def tearDownClass(cls):
- """Remove temporary region"""
- cls.del_temp_region()
-
- def test_remove_procedure(self):
- """Test that maps are removed only with -f"""
- for i in range(0, 10):
- rmapcalc("test_map_%i = 100" % i)
- rmapcalc("test_two = 2")
-
- module = SimpleModule('g.mremove',
- type='rast', pattern='test_map_*,*two')
- self.assertModule(module)
- self.assertMultiLineEqual(module.outputs.stdout,
- REMOVE_RASTERS.replace('user1',
- get_current_mapset()))
-
- module = SimpleModule('g.mremove', type='rast',
- pattern='test_map_*,*two', flags='f')
- self.assertModule(module)
- self.assertMultiLineEqual(module.outputs.stdout, '')
- self.assertMultiLineEqual(module.outputs.stderr, REMOVING_RASTERS_LOG)
-
- def test_remove_procedure_exclude(self):
- """Test that exclude does not list excluded maps"""
- rmapcalc("test_apples = 100")
- rmapcalc("test_oranges = 200")
- rmapcalc("test_apples_big = 300")
- rmapcalc("test_apples_small = 300")
- module = SimpleModule('g.mremove', type='rast',
- pattern='test_{apples,oranges}*',
- exclude="*_small")
- self.assertModule(module)
- self.assertMultiLineEqual(module.outputs.stdout,
- 'rast/test_apples at user1\n'
- 'rast/test_apples_big at user1\n'
- 'rast/test_oranges at user1\n'.replace(
- 'user1', get_current_mapset()))
- module = SimpleModule('g.mremove', type='rast',
- pattern='test_{apples,oranges}{_small,_big,*}',
- flags='f')
- self.assertModule(module)
- self.assertMultiLineEqual(module.outputs.stdout, '')
- self.assertRegexpMatches(module.outputs.stderr, "(.*<.+>[^\n]*\n){4}",
- msg="4 maps should be removed")
-
-
-class GMRemoveWrongInputTest(grass.gunittest.TestCase):
- """Test wrong input of parameters for g.mlist module"""
-
- def test_re_flags(self):
- """Test that -r and -e flags are exclusive"""
- module = SimpleModule('g.mremove', flags='re',
- type='rast', pattern='xxxyyyzzz')
- self.assertModuleFail(module)
- stderr = module.outputs.stderr
- self.assertIn('-r', stderr)
- self.assertIn('-e', stderr)
-
-
-if __name__ == '__main__':
- grass.gunittest.test()
Copied: grass/trunk/general/g.remove/testsuite/test_g_remove.py (from rev 62010, grass/trunk/general/g.remove/testsuite/test_g_mremove.py)
===================================================================
--- grass/trunk/general/g.remove/testsuite/test_g_remove.py (rev 0)
+++ grass/trunk/general/g.remove/testsuite/test_g_remove.py 2014-09-17 13:53:13 UTC (rev 62011)
@@ -0,0 +1,109 @@
+"""Test of g.remove module"""
+
+# TODO: rmapcalc probably fatals, replace or add raise on error?
+from grass.script.raster import mapcalc as rmapcalc
+
+import grass.gunittest
+from grass.gunittest.gutils import get_current_mapset
+from grass.gunittest.gmodules import SimpleModule
+
+# when used user1 must be replaced by current mapset
+REMOVE_RASTERS = """rast/test_map_0 at user1
+rast/test_map_1 at user1
+rast/test_map_2 at user1
+rast/test_map_3 at user1
+rast/test_map_4 at user1
+rast/test_map_5 at user1
+rast/test_map_6 at user1
+rast/test_map_7 at user1
+rast/test_map_8 at user1
+rast/test_map_9 at user1
+rast/test_two at user1
+"""
+
+REMOVING_RASTERS_LOG = """Removing raster <test_map_0>
+Removing raster <test_map_1>
+Removing raster <test_map_2>
+Removing raster <test_map_3>
+Removing raster <test_map_4>
+Removing raster <test_map_5>
+Removing raster <test_map_6>
+Removing raster <test_map_7>
+Removing raster <test_map_8>
+Removing raster <test_map_9>
+Removing raster <test_two>
+"""
+
+
+class GMRemoveTest(grass.gunittest.TestCase):
+ """Test removing with g.remove"""
+
+ @classmethod
+ def setUpClass(cls):
+ """Set up small region for fast map creation."""
+ cls.use_temp_region()
+ cls.runModule("g.region", s=0, n=5, w=0, e=5, res=1)
+
+ @classmethod
+ def tearDownClass(cls):
+ """Remove temporary region"""
+ cls.del_temp_region()
+
+ def test_remove_procedure(self):
+ """Test that maps are removed only with -f"""
+ for i in range(0, 10):
+ rmapcalc("test_map_%i = 100" % i)
+ rmapcalc("test_two = 2")
+
+ module = SimpleModule('g.remove',
+ type='rast', pattern='test_map_*,*two')
+ self.assertModule(module)
+ self.assertMultiLineEqual(module.outputs.stdout,
+ REMOVE_RASTERS.replace('user1',
+ get_current_mapset()))
+
+ module = SimpleModule('g.remove', type='rast',
+ pattern='test_map_*,*two', flags='f')
+ self.assertModule(module)
+ self.assertMultiLineEqual(module.outputs.stdout, '')
+ self.assertMultiLineEqual(module.outputs.stderr, REMOVING_RASTERS_LOG)
+
+ def test_remove_procedure_exclude(self):
+ """Test that exclude does not list excluded maps"""
+ rmapcalc("test_apples = 100")
+ rmapcalc("test_oranges = 200")
+ rmapcalc("test_apples_big = 300")
+ rmapcalc("test_apples_small = 300")
+ module = SimpleModule('g.remove', type='rast',
+ pattern='test_{apples,oranges}*',
+ exclude="*_small")
+ self.assertModule(module)
+ self.assertMultiLineEqual(module.outputs.stdout,
+ 'rast/test_apples at user1\n'
+ 'rast/test_apples_big at user1\n'
+ 'rast/test_oranges at user1\n'.replace(
+ 'user1', get_current_mapset()))
+ module = SimpleModule('g.remove', type='rast',
+ pattern='test_{apples,oranges}{_small,_big,*}',
+ flags='f')
+ self.assertModule(module)
+ self.assertMultiLineEqual(module.outputs.stdout, '')
+ self.assertRegexpMatches(module.outputs.stderr, "(.*<.+>[^\n]*\n){4}",
+ msg="4 maps should be removed")
+
+
+class GMRemoveWrongInputTest(grass.gunittest.TestCase):
+ """Test wrong input of parameters for g.remove module"""
+
+ def test_re_flags(self):
+ """Test that -r and -e flags are exclusive"""
+ module = SimpleModule('g.remove', flags='re',
+ type='rast', pattern='xxxyyyzzz')
+ self.assertModuleFail(module)
+ stderr = module.outputs.stderr
+ self.assertIn('-r', stderr)
+ self.assertIn('-e', stderr)
+
+
+if __name__ == '__main__':
+ grass.gunittest.test()
More information about the grass-commit
mailing list