climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r1566134 - /incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py
Date Sat, 08 Feb 2014 21:00:34 GMT
Author: joyce
Date: Sat Feb  8 21:00:33 2014
New Revision: 1566134

URL: http://svn.apache.org/r1566134
Log:
CLIMATE-332 - Add RCMED load test.

Modified:
    incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py

Modified: incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py?rev=1566134&r1=1566133&r2=1566134&view=diff
==============================================================================
--- incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py (original)
+++ incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py Sat Feb  8 21:00:33 2014
@@ -1,6 +1,7 @@
 import os
 import unittest
 from urllib import urlretrieve
+import datetime as dt
 
 from webtest import TestApp
 
@@ -8,6 +9,7 @@ from backend.run_webservices import app
 import backend.processing as bp
 
 import ocw.metrics as metrics
+import ocw.data_source.rcmed as rcmed
 
 import numpy
 
@@ -40,6 +42,37 @@ class TestLocalDatasetLoad(unittest.Test
         dataset = bp._load_local_dataset_object(dataset_object)
         self.assertEqual(dataset.variable, dataset_object['var_name'])
 
+class TestRCMEDDatasetLoad(unittest.TestCase):
+    def test_valid_load(self):
+        metadata = rcmed.get_parameters_metadata()
+        # Load TRMM from RCMED
+        dataset_dat = [m for m in metadata if m['parameter_id'] == '36'][0]
+
+        dataset_info = {
+            'dataset_id': int(dataset_dat['dataset_id']),
+            'parameter_id': int(dataset_dat['parameter_id'])
+        }
+
+        eval_bounds = {
+            'start_time': dt.datetime(1998, 02, 01),
+            'end_time': dt.datetime(1998, 03, 01),
+            'lat_min': -10,
+            'lat_max': 10,
+            'lon_min': -15,
+            'lon_max': 15
+        }
+
+        dataset = bp._load_rcmed_dataset_object(dataset_info, eval_bounds)
+        lat_min, lat_max, lon_min, lon_max = dataset.spatial_boundaries()
+        start_time, end_time = dataset.time_range()
+
+        self.assertTrue(eval_bounds['lat_min'] <= lat_min)
+        self.assertTrue(eval_bounds['lat_max'] >= lat_max)
+        self.assertTrue(eval_bounds['lon_min'] <= lon_min)
+        self.assertTrue(eval_bounds['lon_max'] >= lon_max)
+        self.assertTrue(eval_bounds['start_time'] <= start_time)
+        self.assertTrue(eval_bounds['end_time'] >= end_time)
+
 class TestMetricLoad(unittest.TestCase):
     def test_get_valid_metric_options(self):
         metric_map = bp._get_valid_metric_options()



Mime
View raw message