[GRASS-SVN] r62022 - grass/trunk/temporal/t.connect/testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 17 12:37:16 PDT 2014


Author: huhabla
Date: 2014-09-17 12:37:16 -0700 (Wed, 17 Sep 2014)
New Revision: 62022

Modified:
   grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster.py
Log:
temporal modules testsuite: Tests for mixing shared and distributed temporal databases

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	2014-09-17 17:52:37 UTC (rev 62021)
+++ grass/trunk/temporal/t.connect/testsuite/test_distr_tgis_db_raster.py	2014-09-17 19:37:16 UTC (rev 62022)
@@ -13,18 +13,18 @@
 from grass.gunittest.case import TestCase
 from grass.gunittest.gmodules import SimpleModule
 import os
+import grass.temporal as tgis
 
-
 mapset_count = 0
 class TestRasterExtraction(TestCase):
 
     @classmethod
     def setUpClass(cls):
-       os.putenv("GRASS_OVERWRITE", "1")
-       for i in range(1, 5): 
+        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)
-            # Use always the current mapset as temporal database
+            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")
@@ -35,13 +35,40 @@
                                          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("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)
+
+        for i in range(5, 7): 
+            cls.runModule("g.mapset", mapset="test%i"%i)
+            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="rast",  input="A",  
+                                         maps="a1,a2,a3",  
+                                         start="2001-01-01", increment="%i months"%i)
+
     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|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")
         
@@ -114,6 +141,20 @@
         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")
+        self.assertModule(trast_list)
+
+        out = trast_list.outputs["stdout"].value
+
+        for a,  b in zip(list_string.split("\n"),  out.split("\n")):
+            self.assertEqual(a.strip(), b.strip())
+
     def test_strds_info(self):  
         self.runModule("g.mapset", mapset="test4")
         tinfo_string="""id=A at test1
@@ -159,6 +200,16 @@
         info = SimpleModule("t.info", flags="g", input="A at test4")
         self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
 
+        tinfo_string="""id=A at test5
+                                    name=A
+                                    mapset=test5
+                                    start_time=2001-01-01 00:00:00
+                                    end_time=2002-04-01 00:00:00
+                                    granularity=5 months"""
+
+        info = SimpleModule("t.info", flags="g", input="A at test5")
+        self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
     def test_raster_info(self):  
         self.runModule("g.mapset", mapset="test3")
         tinfo_string="""id=a1 at test1
@@ -201,6 +252,16 @@
         info = SimpleModule("t.info", flags="g", type="rast",  input="a1 at test4")
         self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
 
+        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="rast",  input="a1 at test5")
+        self.assertModuleKeyValue(module=info, reference=tinfo_string, precision=2, sep="=")
+
 if __name__ == '__main__':
     from grass.gunittest.main import test
     test()



More information about the grass-commit mailing list