class TestAll(unittest.TestCase): """Test fixes for allvars.""" def setUp(self): """Prepare tests.""" self.cube = Cube([[1.0, 2.0], [3.0, 4.0]], var_name='co2', units='J') self.cube.add_dim_coord( DimCoord([0, 1], standard_name='time', units=Unit('days since 0000-01-01 00:00:00', calendar='gregorian')), 0) self.cube.add_dim_coord(DimCoord([0, 1], long_name='AR5PL35'), 1) self.fix = AllVars() def test_get(self): """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'MIROC-ESM', 'tos'), [AllVars()]) def test_fix_metadata_plev(self): """Test plev fix.""" time = self.cube.coord('time') time.units = Unit("days since 1-1-1", time.units.calendar) cube = self.fix.fix_metadata([self.cube])[0] cube.coord('air_pressure') def test_fix_metadata_no_plev(self): """Test plev fix wotk with no plev.""" self.cube.remove_coord('AR5PL35') cube = self.fix.fix_metadata([self.cube])[0] with self.assertRaises(CoordinateNotFoundError): cube.coord('air_pressure')
def setUp(self): """Prepare tests.""" self.cube = Cube([[1.0, 2.0], [3.0, 4.0]], var_name='co2', units='J') self.cube.add_dim_coord( DimCoord([0, 1], standard_name='time', units=Unit('days since 0000-01-01 00:00:00', calendar='gregorian')), 0) self.cube.add_dim_coord(DimCoord([0, 1], long_name='AR5PL35'), 1) self.fix = AllVars()
def test_get(self): """Test fix get""" self.assertListEqual(Fix.get_fixes('CMIP5', 'MIROC-ESM', 'tos'), [AllVars()])
def test_get(self): """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MIROC-ESM', 'Amon', 'tro3'), [Tro3(None), AllVars(None)])
def test_get(self): """Test fix get.""" self.assertListEqual( Fix.get_fixes('CMIP5', 'MIROC-ESM', 'Amon', 'co2'), [Co2(self.vardef), AllVars(self.vardef)])
def test_get_cl_fix(): """Test getting of fix.""" fix = Fix.get_fixes('CMIP5', 'MIROC-ESM', 'Amon', 'cl') assert fix == [Cl(None), AllVars(None)]