You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by jo...@apache.org on 2013/08/15 21:57:34 UTC
svn commit: r1514459 -
/incubator/climate/branches/RefactorInput/ocw/tests/test_dataset_processor.py
Author: joyce
Date: Thu Aug 15 19:57:34 2013
New Revision: 1514459
URL: http://svn.apache.org/r1514459
Log:
CLIMATE-237 - Add more bad subregion tests for subset().
Modified:
incubator/climate/branches/RefactorInput/ocw/tests/test_dataset_processor.py
Modified: incubator/climate/branches/RefactorInput/ocw/tests/test_dataset_processor.py
URL: http://svn.apache.org/viewvc/incubator/climate/branches/RefactorInput/ocw/tests/test_dataset_processor.py?rev=1514459&r1=1514458&r2=1514459&view=diff
==============================================================================
--- incubator/climate/branches/RefactorInput/ocw/tests/test_dataset_processor.py (original)
+++ incubator/climate/branches/RefactorInput/ocw/tests/test_dataset_processor.py Thu Aug 15 19:57:34 2013
@@ -166,9 +166,11 @@ class TestSubset(unittest.TestCase):
def test_subset_with_bad_subregion(self):
target_dataset = ten_year_monthly_dataset()
+ target_dataset.lats = np.array(range(-89, 88, 2))
+ target_dataset.lons = np.array(range(-179, 178, 2))
subregion = {
- 'latMin': -91,
+ 'latMin': -81,
'latMax': 81,
'lonMin': -161,
'lonMax': 161,
@@ -176,7 +178,80 @@ class TestSubset(unittest.TestCase):
'end': datetime.datetime(2004, 1, 1)
}
+ # Out of range latMin test
+ subregion['latMin'] = -91
_test_bad_subregion_object(subregion, target_dataset)
+ subregion['latMin'] = -81
+
+ # Out of range latMax test
+ subregion['latMax'] = 91
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['latMax'] = 81
+
+ # Out of range lonMin test
+ subregion['lonMin'] = -191
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['lonMin'] = -161
+
+ # Out of range lonMax test
+ subregion['lonMax'] = 191
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['lonMax'] = 161
+
+ # Out of dataset bounds latMin test
+ subregion['latMin'] = -90
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['latMin'] = -81
+
+ # Out of dataset bounds latMax test
+ subregion['latMax'] = 90
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['latMax'] = 81
+
+ # Out of dataset bounds lonMin test
+ subregion['lonMin'] = -180
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['lonMin'] = -161
+
+ # Out of dataset bounds lonMax test
+ subregion['lonMax'] = 180
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['lonMax'] = 161
+
+ # lat min/max value mismatch
+ subregion['latMin'] = 82
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['latMin'] = -81
+
+ # lon min/max value mismatch
+ subregion['lonMin'] = 162
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['lonMin'] = -161
+
+ # Out of dataset bounds start time test
+ subregion['start'] = datetime.datetime(1999, 1, 1)
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['start'] = datetime.datetime(2001, 1, 1)
+
+ # Out of dataset bounds end time test
+ subregion['end'] = datetime.datetime(2011, 1, 1)
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['end'] = datetime.datetime(2010, 1, 1)
+
+ # Invalid start time
+ subregion['start'] = "This is not a datetime object!!"
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['start'] = datetime.datetime(2001, 1, 1)
+
+ # Invalid end time
+ subregion['end'] = "This is not a datetime object!!"
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['end'] = datetime.datetime(2010, 1, 1)
+
+ # start/end time range mismatch
+ subregion['start'] = datetime.datetime(2010, 2, 2)
+ _test_bad_subregion_object(subregion, target_dataset)
+ subregion['start'] = datetime.datetime(2001, 1, 1)
def ten_year_monthly_dataset():