climate-commits mailing list archives

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

URL: http://svn.apache.org/r1566127
Log:
CLIMATE-332 - Add initial metric loading test

- Remove relative imports of backend modules.
- Move local dataset setUp and tearDown methods out of module scope.
- Add test for get_valid_metric_options.

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=1566127&r1=1566126&r2=1566127&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:21 2014
@@ -4,8 +4,10 @@ from urllib import urlretrieve
 
 from webtest import TestApp
 
-from ..run_webservices import app
-from ..processing import _load_local_dataset_object
+from backend.run_webservices import app
+import backend.processing
+
+import ocw.metrics as metrics
 
 test_app = TestApp(app)
 
@@ -13,15 +15,17 @@ FILE_LEADER = "http://zipper.jpl.nasa.go
 FILE_1 = "AFRICA_KNMI-RACMO2.2b_CTL_ERAINT_MM_50km_1989-2008_tasmax.nc"
 FILE_2 = "AFRICA_UC-WRF311_CTL_ERAINT_MM_50km-rg_1989-2008_tasmax.nc"
 
-def setUpModule(self):
-    if not os.path.exists('test.nc'):
-        urlretrieve(FILE_LEADER + FILE_1, 'test.nc')
-
-def tearDownModule(self):
-    if os.path.exists('test.nc'):
-        os.remove('test.nc')
-
 class TestLocalDatasetLoad(unittest.TestCase):
+    @classmethod
+    def setUpClass(self):
+        if not os.path.exists('test.nc'):
+            urlretrieve(FILE_LEADER + FILE_1, 'test.nc')
+
+    @classmethod
+    def tearDownClass(self):
+        if os.path.exists('test.nc'):
+            os.remove('test.nc')
+
     def test_valid_load(self):
         dataset_object = {
             'id': os.path.abspath('test.nc'),
@@ -31,6 +35,11 @@ class TestLocalDatasetLoad(unittest.Test
             'time_name': 'time'
         }
 
-        dataset = _load_local_dataset_object(dataset_object)
-
+        dataset = backend.processing._load_local_dataset_object(dataset_object)
         self.assertEqual(dataset.variable, dataset_object['var_name'])
+
+class TestMetricLoad(unittest.TestCase):
+    def test_get_valid_metric_options(self):
+        metric_map = backend.processing._get_valid_metric_options()
+        bias = metric_map['Bias']()
+        self.assertTrue(isinstance(bias, metrics.Bias))



Mime
View raw message