def test_load_all_data(): s = datetime(2017, 12, 17) e = datetime(2018, 10, 23) wi = windiris('tests/test_data/windiris') df = wi(s, e, 'inst2') assert df.shape[0] == 27 assert ( df.RWS == [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 ] ).all()
def test_load_one_day(): s = datetime(2017, 12, 17) e = datetime(2017, 12, 18) wi = windiris('tests/test_data/windiris') df = wi(s, e, 'inst2') assert df.shape[0] == 11 assert ( df.RWS == [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ).all() s = datetime(2017, 12, 18) e = datetime(2017, 12, 19) wi = windiris('tests/test_data/windiris') df = wi(s, e, 'inst2') assert df.shape[0] == 10 assert ( df.RWS == [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ] ).all()
def test_timezone(): dates_tzinfo = timezone("Australia/Melbourne") s = datetime(2017, 12, 19) s = dates_tzinfo.localize(s) e = datetime(2017, 12, 20) e = dates_tzinfo.localize(e) data_tzinfo = timezone("Asia/Calcutta") wi = windiris('tests/test_data/windiris', data_tzinfo) df = wi('inst2', s, e) assert df.shape[0] == 10 assert (df.radial_windspeed == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]).all() assert df.index.tz == data_tzinfo
def test_not_directory(): with pytest.raises(ValueError) as exc: windiris('tests/test_data/windiris/inst1/inst1_rtd.db.gz') assert ('not a directory' in str(exc.value))
#!/usr/bin/env python3 from camille.source import windiris from datetime import datetime from pytz import timezone, utc import pytest wi = windiris('tests/test_data/windiris') def test_load_all_data(): s = datetime(2017, 12, 17, tzinfo=utc) e = datetime(2018, 10, 23, tzinfo=utc) df = wi('inst2', s, e) assert df.shape[0] == 27 assert (df.radial_windspeed == [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3 ]).all() def test_load_one_day(): s = datetime(2017, 12, 17, tzinfo=utc) e = datetime(2017, 12, 18, tzinfo=utc) df = wi('inst2', s, e) assert df.shape[0] == 11 assert (df.radial_windspeed == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]).all()