generated from CambridgeEngineering/PartIA-Flood-Warning-System
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_datafetcher.py
36 lines (28 loc) · 971 Bytes
/
test_datafetcher.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
# Copyright (C) 2018 Garth N. Wells
#
# SPDX-License-Identifier: MIT
"""Unit test for the stationdata module"""
import datetime
from floodsystem.datafetcher import fetch_measure_levels
from floodsystem.stationdata import build_station_list
def test_build_station_list():
# Build list of stations
stations = build_station_list()
# Find station 'Cam'
for station in stations:
if station.name == 'Cam':
station_cam = station
break
# Assert that station is found
assert station_cam
# Fetch data over past 2 days
dt = 2
dates2, levels2 = fetch_measure_levels(
station_cam.measure_id, dt=datetime.timedelta(days=dt))
assert len(dates2) == len(levels2)
# Fetch data over past 10 days
dt = 10
dates10, levels10 = fetch_measure_levels(
station_cam.measure_id, dt=datetime.timedelta(days=dt))
assert len(dates10) == len(levels10)
assert len(dates10) > len(levels2)