Return-Path: X-Original-To: apmail-climate-commits-archive@minotaur.apache.org Delivered-To: apmail-climate-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7BA7F10A6F for ; Sat, 8 Feb 2014 21:00:48 +0000 (UTC) Received: (qmail 8731 invoked by uid 500); 8 Feb 2014 21:00:46 -0000 Delivered-To: apmail-climate-commits-archive@climate.apache.org Received: (qmail 8707 invoked by uid 500); 8 Feb 2014 21:00:45 -0000 Mailing-List: contact commits-help@climate.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@climate.incubator.apache.org Delivered-To: mailing list commits@climate.incubator.apache.org Received: (qmail 8637 invoked by uid 99); 8 Feb 2014 21:00:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Feb 2014 21:00:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Feb 2014 21:00:42 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C1E952388C3D; Sat, 8 Feb 2014 21:00:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1566127 - /incubator/climate/trunk/ocw-ui/backend/tests/test_processing.py Date: Sat, 08 Feb 2014 21:00:21 -0000 To: commits@climate.incubator.apache.org From: joyce@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140208210021.C1E952388C3D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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))