-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_ERA5.py
60 lines (43 loc) · 1.99 KB
/
test_ERA5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import unittest
import ECMWF_tools
import ECMWF_query
import ECMWF_convert_to_ROMS
from datetime import datetime
import numpy as np
import xarray as xr
from typing import List
class TestECMWF_init(unittest.TestCase):
def setUp(self):
self.tool = ECMWF_tools.ECMWF_tools()
class TestInit(TestECMWF_init):
def test_init_setup_config(self):
self.assertIsNotNone(self.tool.config_ecmwf)
self.assertIsNotNone(self.tool)
def test_server_not_null(self):
self.assertTrue(self.tool.server)
def test_initial_config_not_null(self):
self.assertIsNotNone(self.tool.config_ecmwf)
def test_initial_config_not_null(self):
self.assertIsNotNone(self.tool.config_ecmwf.time_units)
def test_ecmwf_class_correct(self):
self.assertTrue(self.tool.config_ecmwf.dataset_class in ["ei","ea"])
def test_reference_date_equal_to_ROMS_standard(self):
self.assertTrue(self.tool.config_ecmwf.time_units=="days since 1948-01-01 00:00:00")
def test_initial_start_and_end_dates(self):
self.assertIsNotNone(self.tool.config_ecmwf.start_year)
self.assertIsNotNone(self.tool.config_ecmwf.end_year)
def test_initial_start_and_end_dates_correct_format(self):
self.assertTrue(datetime.strptime(str(self.tool.config_ecmwf.start_year), '%Y'))
self.assertTrue(datetime.strptime(str(self.tool.config_ecmwf.end_year), '%Y'))
def test_initial_variable_and_table_ids_equal_length(self):
self.assertTrue(self.tool.config_ecmwf.reanalysis)
def test_each_variable_has_metadata(self):
for parameter in self.tool.config_ecmwf.parameters:
self.assertIsNotNone(self.tool.config_ecmwf.get_parameter_metadata(parameter))
self.assertEqual(type({}), type(self.tool.config_ecmwf.get_parameter_metadata(parameter)))
def test_each_variable_has_metadata_units(self):
for parameter in self.tool.config_ecmwf.parameters:
self.assertIsNotNone(self.tool.config_ecmwf.get_parameter_metadata(parameter))
self.assertIsNotNone(self.tool.config_ecmwf.get_parameter_metadata(parameter)["units"])
if __name__ == "__main__":
unittest.main()