Commit 99248740 authored by Javier Vegas-Regidor's avatar Javier Vegas-Regidor
Browse files

Fixed tests

parent 6b9c50de
......@@ -28,7 +28,7 @@ class CDFTools(object):
:param output: output file. Not all tools support this parameter
:type options: str
:param options: options for the tool.
:type options: str | list[str] | Tuple[str]
:type options: str | [str] | Tuple[str]
:param log_level: log level at which the output of the cdftool command will be added
:type log_level: int
:param input_option: option to add before input file
......@@ -91,4 +91,4 @@ class CDFTools(object):
exe_file = os.path.join(path, command)
if self.is_exe(exe_file):
return
raise ValueError('Error executing {0}\n Command does not exist in {1}', command, self.path)
raise ValueError('Error executing {0}\n Command does not exist in {1}'.format(command, self.path))
......@@ -5,16 +5,16 @@ from earthdiagnostics.frequency import Frequencies
class ModelingRealm(object):
def __init__(self, domain_name):
domain_name = domain_name.lower()
if domain_name == 'seaice':
lower_name = domain_name.lower()
if lower_name == 'seaice':
self.name = 'seaIce'
elif domain_name == 'landice':
elif lower_name == 'landice':
self.name = 'landIce'
elif domain_name == 'atmoschem':
elif lower_name == 'atmoschem':
self.name = 'atmosChem'
elif domain_name == 'ocnbgchem':
elif lower_name == 'ocnbgchem':
self.name = 'ocnBgchem'
elif domain_name in ['ocean', 'atmos', 'land', 'aerosol']:
elif lower_name in ['ocean', 'atmos', 'land', 'aerosol']:
self.name = domain_name
else:
raise ValueError('Modelling realm {0} not recognized!'.format(domain_name))
......@@ -28,6 +28,9 @@ class ModelingRealm(object):
def __str__(self):
return self.name
def __repr__(self):
return str(self)
def get_table_name(self, frequency, data_convention):
"""
Returns the table name for a domain-frequency pair
......@@ -38,21 +41,24 @@ class ModelingRealm(object):
:return: variable's table name
:rtype: str
"""
if frequency in (Frequencies.monthly, Frequencies.climatology, Frequencies.daily):
if self.name == 'seaIce':
if data_convention in ('specs', 'preface'):
prefix = 'OI'
else:
prefix = 'SI'
elif self.name == 'landIce':
prefix = 'LI'
if self.name == 'seaIce':
if data_convention in ('specs', 'preface'):
prefix = 'OI'
else:
prefix = self.name[0].upper()
table_name = prefix + str(frequency)
elif frequency == Frequencies.six_hourly:
prefix = 'SI'
elif self.name == 'landIce':
prefix = 'LI'
else:
prefix = self.name[0].upper()
if frequency == Frequencies.six_hourly:
table_name = '6hrPlev'
else:
table_name = frequency.frequency
if (frequency in (Frequencies.monthly, Frequencies.climatology)) or data_convention not in ('specs',
'preface'):
table_name = prefix + str(frequency)
else:
table_name = frequency.frequency
return table_name
def get_table(self, frequency, data_convention):
......
......@@ -46,7 +46,8 @@ class Gyres(Diagnostic):
self.model_version == other.model_version
def __str__(self):
return 'Gyres Startdate: {0} Member: {1} Chunk: {2}'.format(self.startdate, self.member, self.chunk)
return 'Gyres Startdate: {0.startdate} Member: {0.member} Chunk: {0.chunk} ' \
'Model version: {0.model_version}'.format(self)
@classmethod
def generate_jobs(cls, diags, options):
......
......@@ -17,7 +17,6 @@ import iris.coords
import math
class ClimatologicalPercentile(Diagnostic):
"""
Calculates the climatological percentiles for the given leadtime
......@@ -73,11 +72,14 @@ class ClimatologicalPercentile(Diagnostic):
self.check_max_value = True
def __eq__(self, other):
return self.domain == other.domain and self.variable == other.variable and self.num_bins == other.num_bins
return self.domain == other.domain and self.variable == other.variable and self.num_bins == other.num_bins and \
self.min_value == other.min_value and self.max_value == other.max_value and \
self.start_year == other.start_year and self.end_year == other.end_year and \
self.forecast_month == other.forecast_month
def __str__(self):
return 'Climatological percentile Variable: {0}:{1} ' \
'Bins: {2}'.format(self.domain, self.variable, self.num_bins)
return 'Climatological percentile Variable: {0.domain}:{0.variable} Period: {0.start_year}-{0.end_year} ' \
'Forecast month: {0.forecast_month} Bins: {0.num_bins}'.format(self)
@classmethod
def generate_jobs(cls, diags, options):
......@@ -206,7 +208,7 @@ class ClimatologicalPercentile(Diagnostic):
def _get_distribution(self):
distribution = {}
for startdate in self.leadtime_files:
Log.debug('Getting data for startdate {0}', startdate)
Log.info('Getting data for startdate {0}', startdate)
data_cube = self._load_cube(startdate)
Log.debug('Discretizing file {0}', data_cube)
......
# coding=utf-8
from test_data_manager import TestConversion
# from test.unit.test_variable import TestVariable
from test_constants import TestBasin, TestBasins
from test_constants import TestBasin
from test_box import TestBox
from test_diagnostic import *
from test_cdftools import TestCDFTools
......
......@@ -2,9 +2,9 @@
from unittest import TestCase
from earthdiagnostics.box import Box
from earthdiagnostics.constants import Basins
from earthdiagnostics.constants import Basins, Basin
from earthdiagnostics.ocean.areamoc import AreaMoc
from mock import Mock
from mock import Mock, patch
class TestAreaMoc(TestCase):
......@@ -12,6 +12,9 @@ class TestAreaMoc(TestCase):
def setUp(self):
self.data_manager = Mock()
self.diags = Mock()
self.basins = Mock()
self.basins.Global = Basin('Global')
self.basins.Atlantic = Basin('Atlantic')
self.box = Box()
self.box.min_lat = 0
......@@ -20,18 +23,29 @@ class TestAreaMoc(TestCase):
self.box.max_depth = 0
self.diags.config.experiment.get_chunk_list.return_value = (('20010101', 0, 0), ('20010101', 0, 1))
self.psi = AreaMoc(self.data_manager, '20000101', 1, 1, Basins.Antarctic, self.box)
self.psi = AreaMoc(self.data_manager, '20000101', 1, 1, self.basins.Atlantic, self.box)
def fake_parse(self, value):
if type(value) is Basin:
return value
if value == 'atl':
value = 'Atlantic'
else:
value = 'Global'
return Basin(value)
@patch.object(Basins, 'parse', fake_parse)
def test_generate_jobs(self):
jobs = AreaMoc.generate_jobs(self.diags, ['diagnostic', '0', '0', '0', '0'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], AreaMoc(self.data_manager, '20010101', 0, 0, Basins.Global, self.box))
self.assertEqual(jobs[1], AreaMoc(self.data_manager, '20010101', 0, 1, Basins.Global, self.box))
self.assertEqual(jobs[0], AreaMoc(self.data_manager, '20010101', 0, 0, self.basins.Global, self.box))
self.assertEqual(jobs[1], AreaMoc(self.data_manager, '20010101', 0, 1, self.basins.Global, self.box))
jobs = AreaMoc.generate_jobs(self.diags, ['diagnostic', '0', '0', '0', '0', 'atl'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], AreaMoc(self.data_manager, '20010101', 0, 0, Basins.Atlantic, self.box))
self.assertEqual(jobs[1], AreaMoc(self.data_manager, '20010101', 0, 1, Basins.Atlantic, self.box))
self.assertEqual(jobs[0], AreaMoc(self.data_manager, '20010101', 0, 0, self.basins.Atlantic, self.box))
self.assertEqual(jobs[1], AreaMoc(self.data_manager, '20010101', 0, 1, self.basins.Atlantic, self.box))
with self.assertRaises(Exception):
AreaMoc.generate_jobs(self.diags, ['diagnostic'])
......@@ -40,4 +54,4 @@ class TestAreaMoc(TestCase):
def test_str(self):
self.assertEquals(str(self.psi), 'Area MOC Startdate: 20000101 Member: 1 Chunk: 1 Box: 0N0 '
'Basin: Antarctic_Ocean')
'Basin: Atlantic')
......@@ -7,38 +7,34 @@ from earthdiagnostics.cdftools import CDFTools
import mock
def mock_exists(path, access=None):
return not os.path.basename(path.startswith('bad'))
class TestCDFTools(TestCase):
def setUp(self):
self.cdftools = CDFTools('')
self.cdftools = CDFTools('/test/path')
mock.patch('os.path.join')
# noinspection PyTypeChecker
@mock.patch('os.path.exists', side_effect=mock_exists)
@mock.patch('os.access', side_effect=mock_exists)
def test_run(self):
# noinspection PyUnusedLocal
def mock_exists(path, access=None):
return not os.path.basename(path.startswith('bad'))
with mock.patch('os.path.exists') as exists_mock:
with mock.patch('os.access') as access_mock:
exists_mock.side_effect = mock_exists
access_mock.side_effect = mock_exists
with mock.patch('earthdiagnostics.utils.Utils.execute_shell_command') as execute_mock:
execute_mock.return_value = ['Command output']
with self.assertRaises(ValueError):
self.cdftools.run('badcommand', input='input_file', output='output_file')
with self.assertRaises(ValueError):
self.cdftools.run('command', input='badinput_file', output='output_file')
with self.assertRaises(ValueError):
self.cdftools.run('command', input=['input_file', 'badinput_file'], output='output_file')
with self.assertRaises(ValueError):
self.cdftools.run('command', input='input_file', output='input_file')
with self.assertRaises(Exception):
self.cdftools.run('command', input='input_file', output='badoutput_file')
self.cdftools.run('command', input='input_file', output='output_file')
self.cdftools.run('command', input='input_file')
self.cdftools.run('command', input=None)
self.cdftools.run('command', input=['input_file', 'input_file2'])
self.cdftools.run('command', input='input_file', options='-o -p')
self.cdftools.run('command', input='input_file', options=('-o', '-p'))
with mock.patch('earthdiagnostics.utils.Utils.execute_shell_command') as execute_mock:
execute_mock.return_value = ['Command output']
with self.assertRaises(ValueError):
self.cdftools.run('badcommand', input='input_file', output='output_file')
with self.assertRaises(ValueError):
self.cdftools.run('command', input='badinput_file', output='output_file')
with self.assertRaises(ValueError):
self.cdftools.run('command', input=['input_file', 'badinput_file'], output='output_file')
with self.assertRaises(ValueError):
self.cdftools.run('command', input='input_file', output='input_file')
with self.assertRaises(Exception):
self.cdftools.run('command', input='input_file', output='badoutput_file')
self.cdftools.run('command', input='input_file', output='output_file')
self.cdftools.run('command', input='input_file')
self.cdftools.run('command', input=None)
self.cdftools.run('command', input=['input_file', 'input_file2'])
self.cdftools.run('command', input='input_file', options='-o -p')
self.cdftools.run('command', input='input_file', options=('-o', '-p'))
......@@ -2,7 +2,8 @@
from unittest import TestCase
from earthdiagnostics.statistics.climatologicalpercentile import ClimatologicalPercentile
from mock import Mock
from earthdiagnostics.diagnostic import DiagnosticVariableOption
from mock import Mock, patch
from earthdiagnostics.modelingrealm import ModelingRealms
......@@ -16,20 +17,40 @@ class TestClimatologicalPercentile(TestCase):
self.diags = Mock()
self.diags.data_manager = self.data_manager
self.diagnostic = ClimatologicalPercentile(self.data_manager, ModelingRealms.ocean, 'var',
[10, 90], 1000, self.diags.config.experiment)
def fake_parse(self, value):
return value
@patch.object(DiagnosticVariableOption, 'parse', fake_parse)
def test_generate_jobs(self):
jobs = ClimatologicalPercentile.generate_jobs(self.diags, ['climpercent', 'ocean', 'var', '1-2', '1000'])
jobs = ClimatologicalPercentile.generate_jobs(self.diags, ['climpercent', 'ocean', 'var', '2000', '2001', '11'])
self.assertEqual(len(jobs), 1)
self.assertEqual(jobs[0], ClimatologicalPercentile(self.data_manager, ModelingRealms.ocean, 'var', [1, 2],
1000, self.diags.config.experiment))
self.assertEqual(jobs[0], ClimatologicalPercentile(self.data_manager, ModelingRealms.ocean, 'var',
2000, 2000, 2001, float('nan'), float('nan'), 11,
self.diags.config.experiment))
jobs = ClimatologicalPercentile.generate_jobs(self.diags, ['climpercent', 'ocean', 'var', '2000', '2001', '11',
'', '0', '40'])
self.assertEqual(len(jobs), 1)
self.assertEqual(jobs[0], ClimatologicalPercentile(self.data_manager, ModelingRealms.ocean, 'var',
2000, 2000, 2001, 0.0, 40.0, 11,
self.diags.config.experiment))
jobs = ClimatologicalPercentile.generate_jobs(self.diags, ['climpercent', 'ocean', 'var', '2000', '2001', '7',
'1000', '', '10'])
self.assertEqual(len(jobs), 1)
self.assertEqual(jobs[0], ClimatologicalPercentile(self.data_manager, ModelingRealms.ocean, 'var',
1000, 2000, 2001, float('nan'), 10.0, 7,
self.diags.config.experiment))
with self.assertRaises(Exception):
ClimatologicalPercentile.generate_jobs(self.diags, ['climpercent'])
with self.assertRaises(Exception):
ClimatologicalPercentile.generate_jobs(self.diags, ['climpercent', '0', '0', '0', '0', '0', '0', '0'])
ClimatologicalPercentile.generate_jobs(self.diags, ['climpercent', '0', '0', '0', '0', '0', '0', '0', '0'])
def test_str(self):
self.assertEquals(str(self.diagnostic), 'Climatological percentile Variable: ocean:var Leadtimes: [10, 90] '
'Bins: 1000')
diagnostic = ClimatologicalPercentile(self.data_manager, ModelingRealms.ocean, 'var',
1000, 2000, 2001, float('nan'), float('nan'), 11,
self.diags.config.experiment)
self.assertEquals(str(diagnostic), 'Climatological percentile Variable: ocean:var Period: 2000-2001 '
'Forecast month: 11 Bins: 1000')
# coding=utf-8
from unittest import TestCase
from earthdiagnostics.diagnostic import DiagnosticVariableOption
from earthdiagnostics.box import Box
from earthdiagnostics.ocean.cutsection import CutSection
from mock import Mock
from mock import Mock, patch
from earthdiagnostics.modelingrealm import ModelingRealms
......@@ -23,6 +24,10 @@ class TestCutSection(TestCase):
self.diags.config.experiment.get_chunk_list.return_value = (('20010101', 0, 0), ('20010101', 0, 1))
self.psi = CutSection(self.data_manager, '20000101', 1, 1, ModelingRealms.atmos, 'var', True, 0)
def fake_parse(self, value):
return value
@patch.object(DiagnosticVariableOption, 'parse', fake_parse)
def test_generate_jobs(self):
jobs = CutSection.generate_jobs(self.diags, ['diagnostic', 'var', 'true', '10'])
self.assertEqual(len(jobs), 2)
......
......@@ -11,7 +11,7 @@ class TestGyres(TestCase):
self.data_manager = Mock()
self.diags = Mock()
self.diags.model_version = 'model_version'
self.diags.config.experiment.model_version = 'model_version'
self.diags.config.experiment.get_chunk_list.return_value = (('20010101', 0, 0), ('20010101', 0, 1))
self.gyres = Gyres(self.data_manager, '20000101', 1, 1, 'model_version')
......@@ -26,4 +26,4 @@ class TestGyres(TestCase):
Gyres.generate_jobs(self.diags, ['diagnostic', '0', '0', '0', '0', '0', '0', '0'])
def test_str(self):
self.assertEquals(str(self.gyres), 'Gyres Startdate: 20000101 Member: 1 Chunk: 1')
self.assertEquals(str(self.gyres), 'Gyres Startdate: 20000101 Member: 1 Chunk: 1 Model version: model_version')
......@@ -23,4 +23,4 @@ class TestHeatContentLayer(TestCase):
self.psi = HeatContentLayer(self.data_manager, '20000101', 1, 1, self.box, self.weight, 0, 10)
def test_str(self):
self.assertEquals(str(self.psi), 'Heat content layer Startdate: 20000101 Member: 1 Chunk: 1 Box: 0m-100m')
self.assertEquals(str(self.psi), 'Heat content layer Startdate: 20000101 Member: 1 Chunk: 1 Box: 0-100m')
......@@ -2,15 +2,18 @@
from unittest import TestCase
from earthdiagnostics.box import Box
from earthdiagnostics.constants import Basins
from earthdiagnostics.constants import Basins, Basin
from earthdiagnostics.ocean.maxmoc import MaxMoc
from mock import Mock
from mock import Mock, patch
class TestMaxMoc(TestCase):
def setUp(self):
self.data_manager = Mock()
self.basins = Mock()
self.basins.Global = Basin('Global')
self.basins.Atlantic = Basin('Atlantic')
self.box = Box(True)
self.box.min_lat = 0.0
......@@ -18,8 +21,20 @@ class TestMaxMoc(TestCase):
self.box.min_depth = 0.0
self.box.max_depth = 0.0
self.maxmoc = MaxMoc(self.data_manager, '20000101', 1, 2000, Basins.Global, self.box)
self.maxmoc = MaxMoc(self.data_manager, '20000101', 1, 2000, self.basins.Global, self.box)
def fake_parse(self, value):
if type(value) is Basin:
return value
if value == 'atl':
value = 'Atlantic'
else:
value = 'Global'
return Basin(value)
@patch.object(Basins, 'parse', fake_parse)
def test_generate_jobs(self):
self.diags = Mock()
self.diags.model_version = 'model_version'
......@@ -29,13 +44,13 @@ class TestMaxMoc(TestCase):
jobs = MaxMoc.generate_jobs(self.diags, ['diagnostic', '0', '0', '0', '0'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], MaxMoc(self.data_manager, '20010101', 0, 2000, Basins.Global, self.box))
self.assertEqual(jobs[1], MaxMoc(self.data_manager, '20010101', 0, 2001, Basins.Global, self.box))
self.assertEqual(jobs[0], MaxMoc(self.data_manager, '20010101', 0, 2000, self.basins.Global, self.box))
self.assertEqual(jobs[1], MaxMoc(self.data_manager, '20010101', 0, 2001, self.basins.Global, self.box))
jobs = MaxMoc.generate_jobs(self.diags, ['diagnostic', '0', '0', '0', '0', 'atl'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], MaxMoc(self.data_manager, '20010101', 0, 2000, Basins.Atlantic, self.box))
self.assertEqual(jobs[1], MaxMoc(self.data_manager, '20010101', 0, 2001, Basins.Atlantic, self.box))
self.assertEqual(jobs[0], MaxMoc(self.data_manager, '20010101', 0, 2000, self.basins.Atlantic, self.box))
self.assertEqual(jobs[1], MaxMoc(self.data_manager, '20010101', 0, 2001, self.basins.Atlantic, self.box))
self.diags.config.experiment.get_full_years.return_value = list()
jobs = MaxMoc.generate_jobs(self.diags, ['diagnostic', '0', '0', '0', '0'])
......@@ -49,4 +64,4 @@ class TestMaxMoc(TestCase):
def test_str(self):
self.assertEquals(str(self.maxmoc), 'Max moc Startdate: 20000101 Member: 1 Year: 2000 '
'Box: 0N0 Basin: Global_Ocean')
'Box: 0.0N0.0m Basin: Global')
......@@ -18,19 +18,19 @@ class TestModellingRealms(TestCase):
class TestModellingRealm(TestCase):
def setUp(self):
self.basin = ModelingRealm('ocean')
self.realm = ModelingRealm('ocean')
def test_constructor_fail_on_bad_realm(self):
with self.assertRaises(ValueError):
ModelingRealm('badrealm')
def test_comparison(self):
self.assertEqual(ModelingRealm('ocean'), self.basin)
self.assertNotEqual(ModelingRealm('OCEAN'), self.basin)
self.assertNotEqual(ModelingRealm('atmos'), self.basin)
self.assertEqual(ModelingRealm('ocean'), self.realm)
self.assertNotEqual(ModelingRealm('OCEAN'), self.realm)
self.assertNotEqual(ModelingRealm('atmos'), self.realm)
def test_get_omon(self):
self.assertEqual(self.basin.get_table_name(Frequencies.monthly, 'specs'), 'Omon')
self.assertEqual(self.realm.get_table_name(Frequencies.monthly, 'specs'), 'Omon')
def test_get_oimon(self):
self.assertEqual(ModelingRealm('seaIce').get_table_name(Frequencies.monthly, 'specs'), 'OImon')
......
# coding=utf-8
from unittest import TestCase
from earthdiagnostics.diagnostic import DiagnosticVariableOption
from earthdiagnostics.box import Box
from earthdiagnostics.frequency import Frequencies
from earthdiagnostics.general.monthlymean import MonthlyMean
from mock import Mock
from mock import Mock, patch
from earthdiagnostics.modelingrealm import ModelingRealms
......@@ -24,23 +25,27 @@ class TestMonthlyMean(TestCase):
self.mixed = MonthlyMean(self.data_manager, '20000101', 1, 1, ModelingRealms.ocean, 'var', 'freq', '')
def fake_parse(self, value):
return value
@patch.object(DiagnosticVariableOption, 'parse', fake_parse)
def test_generate_jobs(self):
jobs = MonthlyMean.generate_jobs(self.diags, ['diagnostic', 'var', 'ocean'])
jobs = MonthlyMean.generate_jobs(self.diags, ['diagnostic', 'ocean', 'var'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], MonthlyMean(self.data_manager, '20010101', 0, 0, ModelingRealms.ocean, 'var',
Frequencies.daily, ''))
self.assertEqual(jobs[1], MonthlyMean(self.data_manager, '20010101', 0, 1, ModelingRealms.ocean, 'var',
Frequencies.daily, ''))
jobs = MonthlyMean.generate_jobs(self.diags, ['diagnostic', 'var', 'atmos', 'monthly'])
jobs = MonthlyMean.generate_jobs(self.diags, ['diagnostic', 'atmos', 'var', 'monthly'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], MonthlyMean(self.data_manager, '20010101', 0, 0, ModelingRealms.atmos, 'var',
Frequencies.monthly, ''))
self.assertEqual(jobs[1], MonthlyMean(self.data_manager, '20010101', 0, 1, ModelingRealms.atmos, 'var',
Frequencies.monthly, ''))
jobs = MonthlyMean.generate_jobs(self.diags, ['diagnostic', 'var', 'seaice', 'mon', 'grid'])
jobs = MonthlyMean.generate_jobs(self.diags, ['diagnostic', 'seaice', 'var', 'mon', 'grid'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], MonthlyMean(self.data_manager, '20010101', 0, 0, ModelingRealms.seaIce, 'var',
Frequencies.monthly, 'grid'))
......
......@@ -24,7 +24,7 @@ class TestMonthlyPercentile(TestCase):
self.diagnostic = MonthlyPercentile(self.data_manager, '20000101', 1, 1, ModelingRealms.ocean, 'var', [10, 90])
def test_generate_jobs(self):
jobs = MonthlyPercentile.generate_jobs(self.diags, ['monpercent', 'var', 'ocean', '10-90'])
jobs = MonthlyPercentile.generate_jobs(self.diags, ['monpercent', 'ocean', 'var', '10-90'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], MonthlyPercentile(self.data_manager, '20010101', 0, 0, ModelingRealms.ocean, 'var',
[10, 90]))
......
# coding=utf-8
from unittest import TestCase
from earthdiagnostics.diagnostic import DiagnosticVariableOption
from earthdiagnostics.box import Box
from earthdiagnostics.general.rewrite import Rewrite
from mock import Mock
from mock import Mock, patch
from earthdiagnostics.modelingrealm import ModelingRealms
......@@ -23,14 +24,18 @@ class TestRewrite(TestCase):
self.mixed = Rewrite(self.data_manager, '20000101', 1, 1, ModelingRealms.atmos, 'var', 'grid')
def fake_parse(self, value):
return value
@patch.object(DiagnosticVariableOption, 'parse', fake_parse)
def test_generate_jobs(self):
jobs = Rewrite.generate_jobs(self.diags, ['diagnostic', 'var', 'atmos'])
jobs = Rewrite.generate_jobs(self.diags, ['diagnostic', 'atmos', 'var'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], Rewrite(self.data_manager, '20010101', 0, 0, ModelingRealms.atmos, 'var', 'original'))
self.assertEqual(jobs[1], Rewrite(self.data_manager, '20010101', 0, 1, ModelingRealms.atmos, 'var', 'original'))
jobs = Rewrite.generate_jobs(self.diags, ['diagnostic', 'var', 'ocean', 'grid'])
jobs = Rewrite.generate_jobs(self.diags, ['diagnostic', 'ocean', 'var', 'grid'])
self.assertEqual(len(jobs), 2)
self.assertEqual(jobs[0], Rewrite(self.data_manager, '20010101', 0, 0, ModelingRealms.ocean, 'var', 'grid'))
self.assertEqual(jobs[1], Rewrite(self.data_manager, '20010101', 0, 1, ModelingRealms.ocean, 'var', 'grid'))
......
......@@ -15,7 +15,7 @@ class TestSiasiesiv(TestCase):
self.diags.config.experiment.get_chunk_list.return_value = (('20010101', 0, 0), ('20010101', 0, 1))
self.mask = Mock()
self.psi = Siasiesiv(self.data_manager, '20000101', 1, 1, Basins.Global, self.mask)
self.psi = Siasiesiv(self.data_manager, '20000101', 1, 1, Basins().Global, self.mask)
def test_str(self):
self.assertEquals(str(self.psi), 'Siasiesiv Startdate: 20000101 Member: 1 Chunk: 1 Basin: Global_Ocean')