Commit 3b501989 authored by BorjaEst's avatar BorjaEst
Browse files

Rename test_sources to sources_base

parent 36c46b3e
......@@ -16,8 +16,8 @@ class TestO3SKIM_sources(unittest.TestCase):
def setUp(self):
"""Loads and creates the test folders and files from test_sources.yaml"""
self.config = utils.load("tests/test_sources.yaml")
self.assertTrue(type(self.config) is dict)
self.config_base = utils.load("tests/sources_base.yaml")
self.assertTrue(type(self.config_base) is dict)
self.create_mock_datasets()
self.backup_datasets()
......@@ -28,7 +28,7 @@ class TestO3SKIM_sources(unittest.TestCase):
def create_mock_datasets(self):
"""Creates mock data files according to the loaded configuration"""
for _, collection in self.config.items():
for _, collection in self.config_base.items():
for _, variables in collection.items():
for _, vinfo in variables.items():
path = "data/" + vinfo["dir"]
......@@ -38,7 +38,7 @@ class TestO3SKIM_sources(unittest.TestCase):
def backup_datasets(self):
"""Loads the mock datasets into an internal variable"""
self.ds_backup = {}
for source, collection in self.config.items():
for source, collection in self.config_base.items():
self.ds_backup[source] = {}
for model, variables in collection.items():
self.ds_backup[source][model] = {}
......@@ -49,7 +49,7 @@ class TestO3SKIM_sources(unittest.TestCase):
def assert_with_backup(self):
"""Asserts the dataset in the backup is equal to the config load"""
for source, collection in self.config.items():
for source, collection in self.config_base.items():
for model, variables in collection.items():
for v, vinfo in variables.items():
paths = "data/" + vinfo["dir"] + "/*.nc"
......@@ -61,7 +61,7 @@ class TestO3SKIM_sources(unittest.TestCase):
"""Creates the different sources from the configuration file"""
with utils.cd("data"):
ds = {name: sources.Source(name, collection) for
name, collection in self.config.items()}
name, collection in self.config_base.items()}
# CCMI-1 tco3_zm asserts
self.assertTrue('time' in ds['CCMI-1']._models['IPSL']._tco3_zm.coords)
......@@ -81,7 +81,7 @@ class TestO3SKIM_sources(unittest.TestCase):
"""Skims the data into the output folder"""
with utils.cd("data"):
ds = {name: sources.Source(name, collection) for
name, collection in self.config.items()}
name, collection in self.config_base.items()}
with utils.cd("output"):
[source.skim() for source in ds.values()]
......@@ -100,3 +100,31 @@ class TestO3SKIM_sources(unittest.TestCase):
# Checks the original data has not been modified
self.assert_with_backup()
def test_002_OutputFromSources(self):
"""Skims the data into the output folder"""
with utils.cd("data"):
ds = {name: sources.Source(name, collection) for
name, collection in self.config_base.items()}
with utils.cd("output"):
[source.skim() for source in ds.values()]
# CCMI-1 data skim asserts
self.assertTrue(os.path.isdir("output/CCMI-1_IPSL"))
self.assertTrue(os.path.exists("output/CCMI-1_IPSL/tco3_zm_2000.nc"))
self.assertTrue(os.path.exists("output/CCMI-1_IPSL/vrm_zm_2000.nc"))
# ECMWF data skim asserts
self.assertTrue(os.path.isdir("output/ECMWF_ERA-5"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-5/tco3_zm_2000.nc"))
self.assertTrue(os.path.isdir("output/ECMWF_ERA-i"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-i/tco3_zm_2000.nc"))
self.assertTrue(os.path.exists("output/ECMWF_ERA-i/vrm_zm_2000.nc"))
# Checks the original data has not been modified
self.assert_with_backup()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment