File: usace_rivergages_test.py

package info (click to toggle)
python-ulmo 0.8.5%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,056 kB
  • sloc: python: 6,550; makefile: 144
file content (47 lines) | stat: -rw-r--r-- 1,411 bytes parent folder | download | duplicates (3)
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
import datetime

import ulmo

import test_util


def test_get_stations():
    stations_file = 'usace/rivergages/get_stations.cfm'
    with test_util.mocked_urls(stations_file):
        stations = ulmo.usace.rivergages.get_stations()
    assert len(stations) > 1900
    assert 'CE7F42E6' in stations


def test_get_station_parameters():
    test_sets = [
            ('CE7F42E6', {
                'HP': u'Pool Level (Ft)',
                'PC': u'Cumulative Precipitation (In)'
            })
    ]

    for station_code, test_value in test_sets:
        stations_file = 'usace/rivergages/parameters_%s.cfm' % station_code
        with test_util.mocked_urls(stations_file):
            parameters = ulmo.usace.rivergages.get_station_parameters(station_code)

        assert parameters == test_value


def test_get_station_data():
    test_sets = [
            ('CE7F42E6', [
                (datetime.date(2013, 1, 1), 168.04),
                (datetime.date(2013, 1, 15), 168.69)
            ])
    ]

    for station_code, test_values in test_sets:
        stations_file = 'usace/rivergages/data_%s.cfm' % station_code
        with test_util.mocked_urls(stations_file):
            station_data = ulmo.usace.rivergages.get_station_data('CE7F42E6', 'HP',
                    start='2013-1-1', end='2013-1-15')

        for test_value in test_values:
            assert test_value in iter(station_data.items())