Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ In alphabetical order:
* David Bronaugh
* Rod Glover
* James Hiebert
* Zach Hornung
* Skyler Johnson
* Nikola Rados
* Basil Veerman
* Lee Zeman

23 changes: 21 additions & 2 deletions tests/test_date_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from datetime import datetime
import collections
from nchelpers.exceptions import CFValueError
import pytest

from pytest import mark
from netCDF4 import num2date
Expand All @@ -8,7 +10,8 @@
resolution_standard_name, \
jday_360_to_remapped_month_day, \
to_datetime, \
truncate_to_resolution
truncate_to_resolution, \
time_scale


@mark.parametrize('arg, result', [
Expand Down Expand Up @@ -95,4 +98,20 @@ def test_to_datetime_360(jday_360, month, day):
(datetime(2012, 5, 1), "seasonal", datetime(2012, 3, 1))
])
def test_truncate_to_resolution(date, resolution, expected):
assert(truncate_to_resolution(date, resolution)) == expected
assert(truncate_to_resolution(date, resolution)) == expected

def test_time_scale_error_messages():
with pytest.raises(AttributeError):
time_scale('baby goats')

def test_time_scale_error2():
class BabyGoats:
def __init__(self):
self.units = 'baby goats'
with pytest.raises(CFValueError):
time_scale(BabyGoats())

def test_hours_conversion_for_resolution_standard_name():
seconds = 3600
assert resolution_standard_name(seconds) == '1-hourly'