[GRASS-SVN] r64641 - grass/trunk/temporal/t.connect/testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Feb 15 18:42:06 PST 2015
Author: wenzeslaus
Date: 2015-02-15 18:42:06 -0800 (Sun, 15 Feb 2015)
New Revision: 64641
Modified:
grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster.py
grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster3d.py
grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_vector.py
Log:
t.connect: delete created mapsets in tear down step in tests
* only the given (current) mapset is deleted with automatic runs
* TODO: the names should be more unique or a custom gisdbase should be used
* whitespace and unused variable cleanup using pep8, autopep8, pyflakes and pylint
* before: automatic tests were failing because location already contained the mapsets, so set up step was failing
Modified: grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster.py
===================================================================
--- grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster.py 2015-02-15 23:03:24 UTC (rev 64640)
+++ grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster.py 2015-02-16 02:42:06 UTC (rev 64641)
@@ -8,156 +8,168 @@
:authors: Soeren Gebbert
"""
-import grass.pygrass.modules as pymod
-import subprocess
from grass.gunittest.case import TestCase
from grass.gunittest.gmodules import SimpleModule
+from grass.gunittest.utils import silent_rmtree
import os
import grass.temporal as tgis
-mapset_count = 0
+
class TestRasterExtraction(TestCase):
+ mapsets_to_remove = []
+
@classmethod
def setUpClass(cls):
os.putenv("GRASS_OVERWRITE", "1")
- for i in range(1, 5):
- cls.runModule("g.mapset", flags="c", mapset="test%i"%i)
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
+ for i in range(1, 5):
+ mapset_name = "test%i" % i
+ cls.runModule("g.mapset", flags="c", mapset=mapset_name)
+ cls.mapsets_to_remove.append(mapset_name)
+ cls.runModule("g.region", s=0, n=80,
+ w=0, e=120, b=0, t=50, res=10, res3=10)
cls.runModule("t.info", flags="s")
cls.runModule("r.mapcalc", expression="a1 = 100")
cls.runModule("r.mapcalc", expression="a2 = 200")
cls.runModule("r.mapcalc", expression="a3 = 300")
-
- cls.runModule("t.create", type="strds", temporaltype="absolute",
- output="A", title="A test", description="A test")
- cls.runModule("t.register", flags="i", type="raster", input="A",
- maps="a1,a2,a3",
- start="2001-01-01", increment="%i months"%i)
+ cls.runModule("t.create", type="strds", temporaltype="absolute",
+ output="A", title="A test", description="A test")
+ cls.runModule("t.register", flags="i", type="raster", input="A",
+ maps="a1,a2,a3",
+ start="2001-01-01", increment="%i months" % i)
+
# Here we reuse two mapset to share a temporal databse between mapsets
tgis.init()
ciface = tgis.get_tgis_c_library_interface()
cls.runModule("g.mapset", flags="c", mapset="test5")
driver = ciface.get_driver_name("test1")
database = ciface.get_database_name("test1")
- cls.runModule("t.connect", driver=driver, database=database)
-
+ cls.runModule("t.connect", driver=driver, database=database)
+
cls.runModule("g.mapset", flags="c", mapset="test6")
driver = ciface.get_driver_name("test2")
database = ciface.get_database_name("test2")
- cls.runModule("t.connect", driver=driver, database=database)
+ cls.runModule("t.connect", driver=driver, database=database)
- for i in range(5, 7):
- cls.runModule("g.mapset", mapset="test%i"%i)
+ for i in range(5, 7):
+ mapset_name = "test%i" % i
+ cls.runModule("g.mapset", mapset=mapset_name)
+ cls.mapsets_to_remove.append(mapset_name)
cls.runModule("r.mapcalc", expression="a1 = 100")
cls.runModule("r.mapcalc", expression="a2 = 200")
cls.runModule("r.mapcalc", expression="a3 = 300")
-
- cls.runModule("t.create", type="strds", temporaltype="absolute",
- output="A", title="A test", description="A test")
- cls.runModule("t.register", flags="i", type="raster", input="A",
- maps="a1,a2,a3",
- start="2001-01-01", increment="%i months"%i)
- def test_tlist(self):
+ cls.runModule("t.create", type="strds", temporaltype="absolute",
+ output="A", title="A test", description="A test")
+ cls.runModule("t.register", flags="i", type="raster", input="A",
+ maps="a1,a2,a3",
+ start="2001-01-01", increment="%i months" % i)
+
+ @classmethod
+ def tearDownClass(cls):
+ gisenv = SimpleModule('g.gisenv', get='GISDBASE')
+ cls.runModule(gisenv, expecting_stdout=True)
+ gisdbase = gisenv.outputs.stdout.strip()
+ gisenv = SimpleModule('g.gisenv', get='LOCATION_NAME')
+ cls.runModule(gisenv, expecting_stdout=True)
+ location = gisenv.outputs.stdout.strip()
+ for mapset_name in cls.mapsets_to_remove:
+ mapset_path = os.path.join(gisdbase, location, mapset_name)
+ silent_rmtree(mapset_path)
+
+ def test_tlist(self):
self.runModule("g.mapset", mapset="test1")
-
+
list_string = """A|test1|2001-01-01 00:00:00|2001-04-01 00:00:00|3
A|test2|2001-01-01 00:00:00|2001-07-01 00:00:00|3
A|test3|2001-01-01 00:00:00|2001-10-01 00:00:00|3
A|test4|2001-01-01 00:00:00|2002-01-01 00:00:00|3
A|test5|2001-01-01 00:00:00|2002-04-01 00:00:00|3
A|test6|2001-01-01 00:00:00|2002-07-01 00:00:00|3"""
-
- entries = list_string.split("\n")
-
- t_list = SimpleModule("t.list", quiet=True,
- columns=["name","mapset,start_time","end_time","number_of_maps"],
- type="strds", where='name = "A"')
+
+ t_list = SimpleModule(
+ "t.list", quiet=True,
+ columns=["name", "mapset,start_time", "end_time", "number_of_maps"],
+ type="strds", where='name = "A"')
self.assertModule(t_list)
-
+
out = t_list.outputs["stdout"].value
-
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
-
- def test_trast_list(self):
+
+ def test_trast_list(self):
self.runModule("g.mapset", mapset="test1")
list_string = """a1|test1|2001-01-01 00:00:00|2001-02-01 00:00:00
a2|test1|2001-02-01 00:00:00|2001-03-01 00:00:00
a3|test1|2001-03-01 00:00:00|2001-04-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.rast.list", quiet=True, flags="s", input="A at test1")
+ trast_list = SimpleModule(
+ "t.rast.list", quiet=True, flags="s", input="A at test1")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|test2|2001-01-01 00:00:00|2001-03-01 00:00:00
a2|test2|2001-03-01 00:00:00|2001-05-01 00:00:00
a3|test2|2001-05-01 00:00:00|2001-07-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.rast.list", quiet=True, flags="s", input="A at test2")
+ trast_list = SimpleModule(
+ "t.rast.list", quiet=True, flags="s", input="A at test2")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|test3|2001-01-01 00:00:00|2001-04-01 00:00:00
a2|test3|2001-04-01 00:00:00|2001-07-01 00:00:00
a3|test3|2001-07-01 00:00:00|2001-10-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.rast.list", quiet=True, flags="s", input="A at test3")
+ trast_list = SimpleModule(
+ "t.rast.list", quiet=True, flags="s", input="A at test3")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|test4|2001-01-01 00:00:00|2001-05-01 00:00:00
a2|test4|2001-05-01 00:00:00|2001-09-01 00:00:00
a3|test4|2001-09-01 00:00:00|2002-01-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.rast.list", quiet=True, flags="s", input="A at test4")
+ trast_list = SimpleModule(
+ "t.rast.list", quiet=True, flags="s", input="A at test4")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|test5|2001-01-01 00:00:00|2001-06-01 00:00:00
a2|test5|2001-06-01 00:00:00|2001-11-01 00:00:00
a3|test5|2001-11-01 00:00:00|2002-04-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.rast.list", quiet=True, flags="s", input="A at test5")
+ trast_list = SimpleModule(
+ "t.rast.list", quiet=True, flags="s", input="A at test5")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
- def test_strds_info(self):
+ def test_strds_info(self):
self.runModule("g.mapset", mapset="test4")
- tinfo_string="""id=A at test1
+ tinfo_string = """id=A at test1
name=A
mapset=test1
start_time=2001-01-01 00:00:00
@@ -165,10 +177,11 @@
granularity=1 month"""
info = SimpleModule("t.info", flags="g", input="A at test1")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="test3")
- tinfo_string="""id=A at test2
+ tinfo_string = """id=A at test2
name=A
mapset=test2
start_time=2001-01-01 00:00:00
@@ -176,10 +189,11 @@
granularity=2 months"""
info = SimpleModule("t.info", flags="g", input="A at test2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="test2")
- tinfo_string="""id=A at test3
+ tinfo_string = """id=A at test3
name=A
mapset=test3
start_time=2001-01-01 00:00:00
@@ -187,10 +201,11 @@
granularity=3 months"""
info = SimpleModule("t.info", flags="g", input="A at test3")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="test1")
- tinfo_string="""id=A at test4
+ tinfo_string = """id=A at test4
name=A
mapset=test4
start_time=2001-01-01 00:00:00
@@ -198,9 +213,10 @@
granularity=4 months"""
info = SimpleModule("t.info", flags="g", input="A at test4")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=A at test5
+ tinfo_string = """id=A at test5
name=A
mapset=test5
start_time=2001-01-01 00:00:00
@@ -208,59 +224,70 @@
granularity=5 months"""
info = SimpleModule("t.info", flags="g", input="A at test5")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- def test_raster_info(self):
+ def test_raster_info(self):
self.runModule("g.mapset", mapset="test3")
- tinfo_string="""id=a1 at test1
+ tinfo_string = """id=a1 at test1
name=a1
mapset=test1
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-02-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster", input="a1 at test1")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster", input="a1 at test1")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at test2
+ tinfo_string = """id=a1 at test2
name=a1
mapset=test2
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-03-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster", input="a1 at test2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster", input="a1 at test2")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at test3
+ tinfo_string = """id=a1 at test3
name=a1
mapset=test3
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-04-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster", input="a1 at test3")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster", input="a1 at test3")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at test4
+ tinfo_string = """id=a1 at test4
name=a1
mapset=test4
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-05-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster", input="a1 at test4")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster", input="a1 at test4")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at test5
+ tinfo_string = """id=a1 at test5
name=a1
mapset=test5
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-06-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster", input="a1 at test5")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster", input="a1 at test5")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
if __name__ == '__main__':
from grass.gunittest.main import test
Modified: grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster3d.py
===================================================================
--- grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster3d.py 2015-02-15 23:03:24 UTC (rev 64640)
+++ grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster3d.py 2015-02-16 02:42:06 UTC (rev 64641)
@@ -8,65 +8,82 @@
:authors: Soeren Gebbert
"""
-import grass.pygrass.modules as pymod
from grass.gunittest.case import TestCase
from grass.gunittest.gmodules import SimpleModule
+from grass.gunittest.utils import silent_rmtree
import os
+
class testRaster3dExtraction(TestCase):
+ mapsets_to_remove = []
+
@classmethod
def setUpClass(cls):
- os.putenv("GRASS_OVERWRITE", "1")
- for i in range(1, 5):
- cls.runModule("g.mapset", flags="c", mapset="test3d%i"%i)
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
+ os.putenv("GRASS_OVERWRITE", "1")
+ for i in range(1, 5):
+ mapset_name = "test3d%i" % i
+ cls.runModule("g.mapset", flags="c", mapset=mapset_name)
+ cls.mapsets_to_remove.append(mapset_name)
+ cls.runModule("g.region", s=0, n=80,
+ w=0, e=120, b=0, t=50, res=10, res3=10)
# Use always the current mapset as temporal database
cls.runModule("r3.mapcalc", expression="a1 = 100")
cls.runModule("r3.mapcalc", expression="a2 = 200")
cls.runModule("r3.mapcalc", expression="a3 = 300")
-
- cls.runModule("t.create", type="str3ds", temporaltype="absolute",
- output="A", title="A test3d", description="A test3d")
- cls.runModule("t.register", flags="i", type="raster_3d", input="A",
- maps="a1,a2,a3",
- start="2001-01-01", increment="%i months"%i)
- def test_tlist(self):
+ cls.runModule("t.create", type="str3ds", temporaltype="absolute",
+ output="A", title="A test3d", description="A test3d")
+ cls.runModule(
+ "t.register", flags="i", type="raster_3d", input="A",
+ maps="a1,a2,a3",
+ start="2001-01-01", increment="%i months" % i)
+
+ @classmethod
+ def tearDownClass(cls):
+ gisenv = SimpleModule('g.gisenv', get='GISDBASE')
+ cls.runModule(gisenv, expecting_stdout=True)
+ gisdbase = gisenv.outputs.stdout.strip()
+ gisenv = SimpleModule('g.gisenv', get='LOCATION_NAME')
+ cls.runModule(gisenv, expecting_stdout=True)
+ location = gisenv.outputs.stdout.strip()
+ for mapset_name in cls.mapsets_to_remove:
+ mapset_path = os.path.join(gisdbase, location, mapset_name)
+ silent_rmtree(mapset_path)
+
+ def test_tlist(self):
self.runModule("g.mapset", mapset="test3d1")
-
+
list_string = """A|test3d1|2001-01-01 00:00:00|2001-04-01 00:00:00|3
A|test3d2|2001-01-01 00:00:00|2001-07-01 00:00:00|3
A|test3d3|2001-01-01 00:00:00|2001-10-01 00:00:00|3
A|test3d4|2001-01-01 00:00:00|2002-01-01 00:00:00|3"""
-
- entries = list_string.split("\n")
-
- t_list = SimpleModule("t.list", quiet=True,
- columns=["name","mapset,start_time","end_time","number_of_maps"],
- type="str3ds", where='name = "A"')
+
+ t_list = SimpleModule(
+ "t.list", quiet=True,
+ columns=["name", "mapset,start_time", "end_time", "number_of_maps"],
+ type="str3ds", where='name = "A"')
self.assertModule(t_list)
-
+
out = t_list.outputs["stdout"].value
-
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
-
- def test_trast_list(self):
+
+ def test_trast_list(self):
self.runModule("g.mapset", mapset="test3d1")
list_string = """a1|test3d1|2001-01-01 00:00:00|2001-02-01 00:00:00
a2|test3d1|2001-02-01 00:00:00|2001-03-01 00:00:00
a3|test3d1|2001-03-01 00:00:00|2001-04-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.rast3d.list", quiet=True, flags="s", input="A at test3d1")
+ trast_list = SimpleModule(
+ "t.rast3d.list", quiet=True, flags="s", input="A at test3d1")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|test3d2|2001-01-01 00:00:00|2001-03-01 00:00:00
@@ -75,12 +92,13 @@
entries = list_string.split("\n")
- trast_list = SimpleModule("t.rast3d.list", quiet=True, flags="s", input="A at test3d2")
+ trast_list = SimpleModule(
+ "t.rast3d.list", quiet=True, flags="s", input="A at test3d2")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|test3d3|2001-01-01 00:00:00|2001-04-01 00:00:00
@@ -89,114 +107,130 @@
entries = list_string.split("\n")
- trast_list = SimpleModule("t.rast3d.list", quiet=True, flags="s", input="A at test3d3")
+ trast_list = SimpleModule(
+ "t.rast3d.list", quiet=True, flags="s", input="A at test3d3")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|test3d4|2001-01-01 00:00:00|2001-05-01 00:00:00
a2|test3d4|2001-05-01 00:00:00|2001-09-01 00:00:00
a3|test3d4|2001-09-01 00:00:00|2002-01-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.rast3d.list", quiet=True, flags="s", input="A at test3d4")
+ trast_list = SimpleModule(
+ "t.rast3d.list", quiet=True, flags="s", input="A at test3d4")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
- def test_strds_info(self):
+ def test_strds_info(self):
self.runModule("g.mapset", mapset="test3d4")
- tinfo_string="""id=A at test3d1
+ tinfo_string = """id=A at test3d1
name=A
mapset=test3d1
start_time=2001-01-01 00:00:00
end_time=2001-04-01 00:00:00
granularity=1 month"""
- info = SimpleModule("t.info", flags="g", type="str3ds", input="A at test3d1")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ info = SimpleModule(
+ "t.info", flags="g", type="str3ds", input="A at test3d1")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="test3d3")
- tinfo_string="""id=A at test3d2
+ tinfo_string = """id=A at test3d2
name=A
mapset=test3d2
start_time=2001-01-01 00:00:00
end_time=2001-07-01 00:00:00
granularity=2 months"""
- info = SimpleModule("t.info", flags="g", type="str3ds", input="A at test3d2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ info = SimpleModule(
+ "t.info", flags="g", type="str3ds", input="A at test3d2")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="test3d2")
- tinfo_string="""id=A at test3d3
+ tinfo_string = """id=A at test3d3
name=A
mapset=test3d3
start_time=2001-01-01 00:00:00
end_time=2001-10-01 00:00:00
granularity=3 months"""
- info = SimpleModule("t.info", flags="g", type="str3ds", input="A at test3d3")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ info = SimpleModule(
+ "t.info", flags="g", type="str3ds", input="A at test3d3")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="test3d1")
- tinfo_string="""id=A at test3d4
+ tinfo_string = """id=A at test3d4
name=A
mapset=test3d4
start_time=2001-01-01 00:00:00
end_time=2002-01-01 00:00:00
granularity=4 months"""
- info = SimpleModule("t.info", flags="g", type="str3ds", input="A at test3d4")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="str3ds", input="A at test3d4")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- def test_raster_info(self):
+ def test_raster_info(self):
self.runModule("g.mapset", mapset="test3d3")
- tinfo_string="""id=a1 at test3d1
+ tinfo_string = """id=a1 at test3d1
name=a1
mapset=test3d1
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-02-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster_3d", input="a1 at test3d1")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster_3d", input="a1 at test3d1")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at test3d2
+ tinfo_string = """id=a1 at test3d2
name=a1
mapset=test3d2
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-03-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster_3d", input="a1 at test3d2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster_3d", input="a1 at test3d2")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at test3d3
+ tinfo_string = """id=a1 at test3d3
name=a1
mapset=test3d3
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-04-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster_3d", input="a1 at test3d3")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster_3d", input="a1 at test3d3")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at test3d4
+ tinfo_string = """id=a1 at test3d4
name=a1
mapset=test3d4
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-05-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="raster_3d", input="a1 at test3d4")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="raster_3d", input="a1 at test3d4")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
if __name__ == '__main__':
from grass.gunittest.main import test
Modified: grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_vector.py
===================================================================
--- grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_vector.py 2015-02-15 23:03:24 UTC (rev 64640)
+++ grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_vector.py 2015-02-16 02:42:06 UTC (rev 64641)
@@ -8,205 +8,232 @@
:authors: Soeren Gebbert
"""
-import grass.pygrass.modules as pymod
-import subprocess
from grass.gunittest.case import TestCase
from grass.gunittest.gmodules import SimpleModule
+from grass.gunittest.utils import silent_rmtree
import os
-mapset_count = 0
+
class TestRasterExtraction(TestCase):
+ mapsets_to_remove = []
+
@classmethod
def setUpClass(cls):
- os.putenv("GRASS_OVERWRITE", "1")
- for i in range(1, 5):
- cls.runModule("g.mapset", flags="c", mapset="testvect%i"%i)
- cls.runModule("g.region", s=0, n=80, w=0, e=120, b=0, t=50, res=10, res3=10)
+ os.putenv("GRASS_OVERWRITE", "1")
+ for i in range(1, 5):
+ mapset_name = "testvect%i" % i
+ cls.runModule("g.mapset", flags="c", mapset=mapset_name)
+ cls.mapsets_to_remove.append(mapset_name)
+ cls.runModule("g.region", s=0, n=80,
+ w=0, e=120, b=0, t=50, res=10, res3=10)
# Use always the current mapset as temporal database
- cls.runModule("v.random", output="a1", npoints=20)
- cls.runModule("v.random", output="a2", npoints=20)
- cls.runModule("v.random", output="a3", npoints=20)
-
- cls.runModule("t.create", type="stvds", temporaltype="absolute",
- output="A", title="A testvect", description="A testvect")
- cls.runModule("t.register", flags="i", type="vector", input="A",
- maps="a1,a2,a3",
- start="2001-01-01", increment="%i months"%i)
+ cls.runModule("v.random", output="a1", npoints=20)
+ cls.runModule("v.random", output="a2", npoints=20)
+ cls.runModule("v.random", output="a3", npoints=20)
- def test_tlist(self):
+ cls.runModule("t.create", type="stvds", temporaltype="absolute",
+ output="A", title="A testvect", description="A testvect")
+ cls.runModule("t.register", flags="i", type="vector", input="A",
+ maps="a1,a2,a3",
+ start="2001-01-01", increment="%i months" % i)
+
+ @classmethod
+ def tearDownClass(cls):
+ gisenv = SimpleModule('g.gisenv', get='GISDBASE')
+ cls.runModule(gisenv, expecting_stdout=True)
+ gisdbase = gisenv.outputs.stdout.strip()
+ gisenv = SimpleModule('g.gisenv', get='LOCATION_NAME')
+ cls.runModule(gisenv, expecting_stdout=True)
+ location = gisenv.outputs.stdout.strip()
+ for mapset_name in cls.mapsets_to_remove:
+ mapset_path = os.path.join(gisdbase, location, mapset_name)
+ silent_rmtree(mapset_path)
+
+ def test_tlist(self):
self.runModule("g.mapset", mapset="testvect1")
-
+
list_string = """A|testvect1|2001-01-01 00:00:00|2001-04-01 00:00:00|3
A|testvect2|2001-01-01 00:00:00|2001-07-01 00:00:00|3
A|testvect3|2001-01-01 00:00:00|2001-10-01 00:00:00|3
A|testvect4|2001-01-01 00:00:00|2002-01-01 00:00:00|3"""
-
- entries = list_string.split("\n")
-
- t_list = SimpleModule("t.list", quiet=True,
- columns=["name","mapset,start_time","end_time","number_of_maps"],
- type="stvds", where='name = "A"')
+
+ t_list = SimpleModule(
+ "t.list", quiet=True,
+ columns=["name", "mapset,start_time", "end_time", "number_of_maps"],
+ type="stvds", where='name = "A"')
self.assertModule(t_list)
-
+
out = t_list.outputs["stdout"].value
-
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
-
- def test_tvect_list(self):
+
+ def test_tvect_list(self):
self.runModule("g.mapset", mapset="testvect1")
list_string = """a1|testvect1|2001-01-01 00:00:00|2001-02-01 00:00:00
a2|testvect1|2001-02-01 00:00:00|2001-03-01 00:00:00
a3|testvect1|2001-03-01 00:00:00|2001-04-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.vect.list", quiet=True, flags="s",
- columns=["name","mapset","start_time","end_time"] ,
+ trast_list = SimpleModule("t.vect.list", quiet=True, flags="s",
+ columns=[
+ "name", "mapset", "start_time", "end_time"],
input="A at testvect1")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|testvect2|2001-01-01 00:00:00|2001-03-01 00:00:00
a2|testvect2|2001-03-01 00:00:00|2001-05-01 00:00:00
a3|testvect2|2001-05-01 00:00:00|2001-07-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.vect.list", quiet=True, flags="s",
- columns=["name","mapset","start_time","end_time"] ,
- input="A at testvect2")
+ trast_list = SimpleModule(
+ "t.vect.list", quiet=True, flags="s",
+ columns=["name", "mapset", "start_time", "end_time"],
+ input="A at testvect2")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|testvect3|2001-01-01 00:00:00|2001-04-01 00:00:00
a2|testvect3|2001-04-01 00:00:00|2001-07-01 00:00:00
a3|testvect3|2001-07-01 00:00:00|2001-10-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.vect.list", quiet=True, flags="s",
- columns=["name","mapset","start_time","end_time"] ,
+ trast_list = SimpleModule("t.vect.list", quiet=True, flags="s",
+ columns=[
+ "name", "mapset", "start_time", "end_time"],
input="A at testvect3")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
list_string = """a1|testvect4|2001-01-01 00:00:00|2001-05-01 00:00:00
a2|testvect4|2001-05-01 00:00:00|2001-09-01 00:00:00
a3|testvect4|2001-09-01 00:00:00|2002-01-01 00:00:00"""
- entries = list_string.split("\n")
-
- trast_list = SimpleModule("t.vect.list", quiet=True, flags="s",
- columns=["name","mapset","start_time","end_time"] ,
- input="A at testvect4")
+ trast_list = SimpleModule(
+ "t.vect.list", quiet=True, flags="s",
+ columns=["name", "mapset", "start_time", "end_time"],
+ input="A at testvect4")
self.assertModule(trast_list)
out = trast_list.outputs["stdout"].value
- for a, b in zip(list_string.split("\n"), out.split("\n")):
+ for a, b in zip(list_string.split("\n"), out.split("\n")):
self.assertEqual(a.strip(), b.strip())
- def test_stvds_info(self):
+ def test_stvds_info(self):
self.runModule("g.mapset", mapset="testvect4")
- tinfo_string="""id=A at testvect1
+ tinfo_string = """id=A at testvect1
name=A
mapset=testvect1
start_time=2001-01-01 00:00:00
end_time=2001-04-01 00:00:00
granularity=1 month"""
- info = SimpleModule("t.info", flags="g", type="stvds", input="A at testvect1")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ info = SimpleModule(
+ "t.info", flags="g", type="stvds", input="A at testvect1")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="testvect3")
- tinfo_string="""id=A at testvect2
+ tinfo_string = """id=A at testvect2
name=A
mapset=testvect2
start_time=2001-01-01 00:00:00
end_time=2001-07-01 00:00:00
granularity=2 months"""
- info = SimpleModule("t.info", flags="g", type="stvds", input="A at testvect2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ info = SimpleModule(
+ "t.info", flags="g", type="stvds", input="A at testvect2")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="testvect2")
- tinfo_string="""id=A at testvect3
+ tinfo_string = """id=A at testvect3
name=A
mapset=testvect3
start_time=2001-01-01 00:00:00
end_time=2001-10-01 00:00:00
granularity=3 months"""
- info = SimpleModule("t.info", flags="g", type="stvds", input="A at testvect3")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
-
+ info = SimpleModule(
+ "t.info", flags="g", type="stvds", input="A at testvect3")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
+
self.runModule("g.mapset", mapset="testvect1")
- tinfo_string="""id=A at testvect4
+ tinfo_string = """id=A at testvect4
name=A
mapset=testvect4
start_time=2001-01-01 00:00:00
end_time=2002-01-01 00:00:00
granularity=4 months"""
- info = SimpleModule("t.info", flags="g", type="stvds", input="A at testvect4")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="stvds", input="A at testvect4")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- def testv_vector_info(self):
+ def testv_vector_info(self):
self.runModule("g.mapset", mapset="testvect3")
- tinfo_string="""id=a1 at testvect1
+ tinfo_string = """id=a1 at testvect1
name=a1
mapset=testvect1
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-02-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="vector", input="a1 at testvect1")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="vector", input="a1 at testvect1")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at testvect2
+ tinfo_string = """id=a1 at testvect2
name=a1
mapset=testvect2
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-03-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="vector", input="a1 at testvect2")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="vector", input="a1 at testvect2")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at testvect3
+ tinfo_string = """id=a1 at testvect3
name=a1
mapset=testvect3
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-04-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="vector", input="a1 at testvect3")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="vector", input="a1 at testvect3")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
- tinfo_string="""id=a1 at testvect4
+ tinfo_string = """id=a1 at testvect4
name=a1
mapset=testvect4
temporal_type=absolute
start_time=2001-01-01 00:00:00
end_time=2001-05-01 00:00:00 """
- info = SimpleModule("t.info", flags="g", type="vector", input="a1 at testvect4")
- self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+ info = SimpleModule(
+ "t.info", flags="g", type="vector", input="a1 at testvect4")
+ self.assertModuleKeyValue(
+ module=info, reference=tinfo_string, precision=2, sep="=")
if __name__ == '__main__':
from grass.gunittest.main import test
More information about the grass-commit
mailing list