generated from CambridgeEngineering/PartIA-Flood-Warning-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_station.py
49 lines (38 loc) · 1.58 KB
/
test_station.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
# Copyright (C) 2018 Garth N. Wells
#
# SPDX-License-Identifier: MIT
"""Unit test for the station module"""
from floodsystem.station import MonitoringStation
from floodsystem.station import inconsistent_typical_range_stations
from floodsystem.stationdata import build_station_list
def test_create_monitoring_station():
# Create a station
s_id = "test-s-id"
m_id = "test-m-id"
label = "some station"
coord = (-2.0, 4.0)
trange = (-2.3, 3.4445)
river = "River X"
town = "My Town"
s = MonitoringStation(s_id, m_id, label, coord, trange, river, town)
assert s.station_id == s_id
assert s.measure_id == m_id
assert s.name == label
assert s.coord == coord
assert s.typical_range == trange
assert s.river == river
assert s.town == town
def test_inconsistent_typical_range():
"""Tests the inconsistent typical range function"""
stations = build_station_list()
test_list = inconsistent_typical_range_stations(stations)
# Checks that typical range data for any station object in the produced list is either unavailable or inconsistent
for station in test_list:
assert station.typical_range is None or station.typical_range[0] > station.typical_range[1]
def test_relative_water_level():
"""Tests the relative water level function"""
test_list = inconsistent_typical_range_stations(build_station_list())
for station in test_list:
assert MonitoringStation.relative_water_level(station) is None
if station.latest_level is None:
assert MonitoringStation.relative_water_level(station) is None