climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [1/8] git commit: CLIMATE-416 - Simplify UI backend test file download
Date Sat, 10 May 2014 19:13:48 GMT
Repository: climate
Updated Branches:
  refs/heads/master 3e79a06c5 -> 574d57762


CLIMATE-416 - Simplify UI backend test file download

- Add package wide test setup.
- Move all example file downloads into the package wide setup. Files are
  only downloaded if they're not currently on the system. This keeps
  stuff from being downloaded every time tests are run.


Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/698f1bac
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/698f1bac
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/698f1bac

Branch: refs/heads/master
Commit: 698f1bacf80f88e73c75bedab8f9daffe139619e
Parents: 3e79a06
Author: Michael Joyce <joyce@apache.org>
Authored: Fri May 9 10:41:20 2014 -0700
Committer: Michael Joyce <joyce@apache.org>
Committed: Fri May 9 10:45:05 2014 -0700

----------------------------------------------------------------------
 ocw-ui/backend/tests/__init__.py        | 13 ++++++++++
 ocw-ui/backend/tests/test_processing.py | 37 +++-------------------------
 2 files changed, 17 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/climate/blob/698f1bac/ocw-ui/backend/tests/__init__.py
----------------------------------------------------------------------
diff --git a/ocw-ui/backend/tests/__init__.py b/ocw-ui/backend/tests/__init__.py
index e69de29..13a4ffd 100644
--- a/ocw-ui/backend/tests/__init__.py
+++ b/ocw-ui/backend/tests/__init__.py
@@ -0,0 +1,13 @@
+import os
+from urllib import urlretrieve
+
+FILE_LEADER = "http://zipper.jpl.nasa.gov/dist/"
+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 setup_package():
+    if not os.path.exists('/tmp/d1.nc'):
+        urlretrieve(FILE_LEADER + FILE_1, '/tmp/d1.nc')
+
+    if not os.path.exists('/tmp/d2.nc'):
+        urlretrieve(FILE_LEADER + FILE_2, '/tmp/d2.nc')

http://git-wip-us.apache.org/repos/asf/climate/blob/698f1bac/ocw-ui/backend/tests/test_processing.py
----------------------------------------------------------------------
diff --git a/ocw-ui/backend/tests/test_processing.py b/ocw-ui/backend/tests/test_processing.py
index ae6331e..f4e0cfa 100644
--- a/ocw-ui/backend/tests/test_processing.py
+++ b/ocw-ui/backend/tests/test_processing.py
@@ -1,6 +1,5 @@
 import os
 import unittest
-from urllib import urlretrieve
 import datetime as dt
 
 from webtest import TestApp
@@ -18,24 +17,10 @@ import numpy
 
 test_app = TestApp(app)
 
-FILE_LEADER = "http://zipper.jpl.nasa.gov/dist/"
-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"
-
 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 setUp(self):
         self.dataset_object = {
-            'dataset_id': os.path.abspath('test.nc'),
+            'dataset_id': os.path.abspath('/tmp/d1.nc'),
             'var_name': 'tasmax',
             'lat_name': 'lat',
             'lon_name': 'lon',
@@ -48,7 +33,7 @@ class TestLocalDatasetLoad(unittest.TestCase):
 
     def test_default_name_assignment(self):
         dataset = bp._load_local_dataset_object(self.dataset_object)
-        self.assertEqual(dataset.name, 'test.nc')
+        self.assertEqual(dataset.name, 'd1.nc')
 
     def test_custom_name_assignment(self):
         self.dataset_object['name'] = 'CustomName'
@@ -261,26 +246,12 @@ class TestPlotTitleCreation(unittest.TestCase):
         )
 
 class TestRunEvaluation(unittest.TestCase):
-    @classmethod
-    def setUpClass(self):
-        if not os.path.exists('d1.nc'):
-            urlretrieve(FILE_LEADER + FILE_1, 'd1.nc')
-        if not os.path.exists('d2.nc'):
-            urlretrieve(FILE_LEADER + FILE_2, 'd2.nc')
-
-    @classmethod
-    def tearDownClass(self):
-        if os.path.exists('d1.nc'):
-            os.remove('d1.nc')
-        if os.path.exists('d2.nc'):
-            os.remove('d2.nc')
-
     def test_full_evaluation(self):
         data = {
             'reference_dataset': {
                 'data_source_id': 1,
                 'dataset_info': {
-                    'dataset_id': os.path.abspath('d1.nc'),
+                    'dataset_id': os.path.abspath('/tmp/d1.nc'),
                     'var_name': 'tasmax',
                     'lat_name': 'lat',
                     'lon_name': 'lon',
@@ -291,7 +262,7 @@ class TestRunEvaluation(unittest.TestCase):
                 {
                     'data_source_id': 1,
                     'dataset_info': {
-                        'dataset_id': os.path.abspath('d2.nc'),
+                        'dataset_id': os.path.abspath('/tmp/d2.nc'),
                         'var_name': 'tasmax',
                         'lat_name': 'lat',
                         'lon_name': 'lon',


Mime
View raw message