[GRASS-SVN] r66525 - in grass/trunk/lib/python/temporal: . testsuite
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 18 18:03:34 PDT 2015
Author: huhabla
Date: 2015-10-18 18:03:34 -0700 (Sun, 18 Oct 2015)
New Revision: 66525
Modified:
grass/trunk/lib/python/temporal/register.py
grass/trunk/lib/python/temporal/testsuite/test_register_function.py
Log:
temporal framework: Better error handling in register function
Modified: grass/trunk/lib/python/temporal/register.py
===================================================================
--- grass/trunk/lib/python/temporal/register.py 2015-10-18 14:05:26 UTC (rev 66524)
+++ grass/trunk/lib/python/temporal/register.py 2015-10-19 01:03:34 UTC (rev 66525)
@@ -79,6 +79,16 @@
msgr.fatal(_("%s= and %s= are mutually exclusive") % ("end",
"increment"))
+ if end and interval:
+ msgr.fatal(_("%s= and the %s flag are mutually exclusive") % ("end",
+ "interval"))
+
+ if increment and not start:
+ msgr.fatal(_("The increment option requires the start option"))
+
+ if interval and not start:
+ msgr.fatal(_("The interval flag requires the start option"))
+
if end and not start:
msgr.fatal(_("Please specify %s= and %s=") % ("start_time",
"end_time"))
@@ -154,6 +164,14 @@
maplist.append(row)
+ if start_time_in_file is True and increment:
+ increment = None
+ msgr.warning(_("The increment option will be ignored because of time stamps in input file"))
+
+ if start_time_in_file is True and interval:
+ increment = None
+ msgr.warning(_("The interval flag will be ignored because of time stamps in input file"))
+
num_maps = len(maplist)
map_object_list = []
statement = ""
Modified: grass/trunk/lib/python/temporal/testsuite/test_register_function.py
===================================================================
--- grass/trunk/lib/python/temporal/testsuite/test_register_function.py 2015-10-18 14:05:26 UTC (rev 66524)
+++ grass/trunk/lib/python/temporal/testsuite/test_register_function.py 2015-10-19 01:03:34 UTC (rev 66525)
@@ -301,5 +301,39 @@
self.assertEqual(end, 2000000)
self.assertEqual(unit, "seconds")
+
+class TestRegisterFails(TestCase):
+
+ def test_error_handling_1(self):
+ # start option is missing
+ self.assertModuleFail("t.register", input="test", end='2001-01-01', maps=("a", "b"))
+
+ def test_error_handling_2(self):
+ # No input definition
+ self.assertModuleFail("t.register", input="test", start='2001-01-01')
+
+ def test_error_handling_3(self):
+ # File and maps are mutually exclusive
+ self.assertModuleFail("t.register", input="test", start='2001-01-01', maps=("a", "b"), file="maps.txt")
+
+ def test_error_handling_4(self):
+ # Increment needs start
+ self.assertModuleFail("t.register", input="test", increment="1 day", maps=("a", "b"))
+
+ def test_error_handling_5(self):
+ # Interval needs start
+ self.assertModuleFail("t.register", flags="i", input="test", maps=("a", "b"))
+
+ def test_error_handling_6(self):
+ # Increment and end are mutually exclusive
+ self.assertModuleFail("t.register", input="test", start='2001-01-01', end='2001-01-01',
+ increment="1 day", maps=("a", "b"))
+
+ def test_error_handling_7(self):
+ # Interval and end are mutually exclusive
+ self.assertModuleFail("t.register", flags="i", input="test", start='2001-01-01', end='2001-01-01',
+ maps=("a", "b"))
+
+
if __name__ == '__main__':
test()
More information about the grass-commit
mailing list