Skip to content

Commit

Permalink
fix get_time test case
Browse files Browse the repository at this point in the history
  • Loading branch information
kouk committed Jul 12, 2017
1 parent 7665f77 commit e6e4926
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/uptime_report/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,20 @@ class Format(Enum):


class TimeUnits(Enum):
"""Enumeration of time division abbreviations."""
"""Enumeration of time division abbreviations.
Attributes:
minutes (str): ``m``
hours (str): ``h``
days (str): ``d``
months (str): ``mo``
years (str): ``y``
"""

minutes = 'm'
hours = 'h'
days = 'd'
months = 'm'
months = 'mo'
years = 'y'


Expand All @@ -77,6 +85,9 @@ def get_time(value, now=None):
>>> get_time('+2d') == now + 2*60*60*24
True
Valid time units for relative values are described in :class:`TimeUnits`.
If a time unit is not provided the default is :py:attr:`TimeUnits.days`.
Additionally, for relative values, the current time can be specified by
passing an :class:`~arrow.arrow.Arrow` instance as the ``now``
argument::
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ def test_get_time():
cli.get_time('-2foo')
assert cli.get_time('', now) == now.timestamp
assert cli.get_time('-2d', now) == now.replace(days=-2).timestamp
assert cli.get_time('-2', now) == now.replace(days=-2).timestamp
assert cli.get_time('-2y', now) == now.replace(years=-2).timestamp
assert cli.get_time('2017-06-01') == arrow.get('2017-06-01').timestamp
assert cli.get_time('-2') == now.replace(days=-2).timestamp

0 comments on commit e6e4926

Please sign in to comment.