Skip to content

Commit 4f51798

Browse files
committed
Add unit tests for YAML config file elements
Add unit tests for production YAML config file elements related to worker; re: issue #117.
1 parent 39a130f commit 4f51798

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

tests/workers/test_get_onc_ferry.py

+82-2
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,90 @@ def test_message_registry_keys(self, prod_config):
8686
"crash",
8787
]
8888

89+
def test_TWDP_ferry_platform(self, prod_config):
90+
ferry_config = prod_config["observations"]["ferry data"]["ferries"]["TWDP"]
91+
assert ferry_config["route name"] == "Tsawwassen - Duke Point"
92+
expected = "Mobile Platforms, British Columbia Ferries, Tsawwassen - Duke Point"
93+
assert ferry_config["ONC station description"] == expected
94+
95+
def test_TWDP_location(self, prod_config):
96+
location_config = prod_config["observations"]["ferry data"]["ferries"]["TWDP"][
97+
"location"
98+
]
99+
assert location_config["stations"] == ["TWDP.N1", "TWDP.N2"]
100+
assert location_config["device category"] == "NAV"
101+
assert location_config["sensors"] == ["longitude", "latitude"]
102+
assert location_config["terminals"] == ["Tsawwassen", "Duke Pt."]
103+
104+
def test_TWDP_devices(self, prod_config):
105+
devices_config = prod_config["observations"]["ferry data"]["ferries"]["TWDP"][
106+
"devices"
107+
]
108+
expected = {
109+
"TSG": {
110+
"sensors": {
111+
"temperature": "temperature",
112+
"conductivity": "conductivity",
113+
"salinity": "salinity",
114+
},
115+
},
116+
"OXYSENSOR": {
117+
"sensors": {
118+
"o2_saturation": "oxygen_saturation",
119+
"o2_concentration_corrected": "oxygen_corrected",
120+
"o2_temperature": "temperature",
121+
},
122+
},
123+
"TURBCHLFL": {
124+
"sensors": {
125+
"cdom_fluorescence": "cdom_fluorescence",
126+
"chlorophyll": "chlorophyll",
127+
"turbidity": "turbidity",
128+
},
129+
},
130+
"CO2SENSOR": {
131+
"sensors": {
132+
"co2_partial_pressure": "partial_pressure",
133+
"co2_concentration_linearized": "co2",
134+
},
135+
},
136+
"TEMPHUMID": {
137+
"sensors": {
138+
"air_temperature": "air_temperature",
139+
"relative_humidity": "rel_humidity",
140+
},
141+
},
142+
"BARPRESS": {
143+
"sensors": {
144+
"barometric_pressure": "barometric_pressure",
145+
},
146+
},
147+
"PYRANOMETER": {
148+
"sensors": {
149+
"solar_radiation": "solar_radiation",
150+
},
151+
},
152+
"PYRGEOMETER": {
153+
"sensors": {
154+
"longwave_radiation": "downward_radiation",
155+
},
156+
},
157+
}
158+
assert devices_config == expected
159+
89160
def test_lon_lat_ji_map_path(self, prod_config):
90161
nemo_ji_map = prod_config["observations"]["lon/lat to NEMO ji map"]
91162
assert nemo_ji_map == "/SalishSeaCast/grid/grid_from_lat_lon_mask999.nc"
92163

164+
def test_TWDP_file_path_template(self, prod_config):
165+
file_path_tmpl = prod_config["observations"]["ferry data"]["ferries"]["TWDP"][
166+
"filepath template"
167+
]
168+
assert (
169+
file_path_tmpl
170+
== "{ferry_platform}/{ferry_platform}_TSG_O2_TURBCHLFL_CO2_METEO_1m_{yyyymmdd}.nc"
171+
)
172+
93173
def test_dest_dir(self, prod_config):
94174
ferry_data_config = prod_config["observations"]["ferry data"]
95175
assert ferry_data_config["dest dir"] == "/results/observations/ONC/ferries/"
@@ -103,7 +183,7 @@ def test_success(self, ferry_platform, caplog):
103183
parsed_args = SimpleNamespace(
104184
ferry_platform=ferry_platform, data_date=arrow.get("2016-09-09")
105185
)
106-
caplog.set_level(logging.INFO)
186+
caplog.set_level(logging.DEBUG)
107187

108188
msg_type = get_onc_ferry.success(parsed_args)
109189

@@ -121,7 +201,7 @@ def test_failure(self, ferry_platform, caplog):
121201
parsed_args = SimpleNamespace(
122202
ferry_platform=ferry_platform, data_date=arrow.get("2016-09-09")
123203
)
124-
caplog.set_level(logging.CRITICAL)
204+
caplog.set_level(logging.DEBUG)
125205

126206
msg_type = get_onc_ferry.failure(parsed_args)
127207

0 commit comments

Comments
 (0)