mirror of
https://github.com/thegeeklab/docker-tidy.git
synced 2024-11-05 04:20:40 +00:00
34 lines
898 B
Python
34 lines
898 B
Python
import datetime
|
|
try:
|
|
from unittest import mock
|
|
except ImportError:
|
|
import mock
|
|
|
|
from dateutil import tz
|
|
|
|
from docker_custodian import args
|
|
|
|
|
|
def test_datetime_seconds_ago(now):
|
|
expected = datetime.datetime(2014, 1, 15, 10, 10, tzinfo=tz.tzutc())
|
|
with mock.patch(
|
|
'docker_custodian.args.datetime.datetime',
|
|
autospec=True,
|
|
) as mock_datetime:
|
|
mock_datetime.now.return_value = now
|
|
assert args.datetime_seconds_ago(24 * 60 * 60 * 5) == expected
|
|
|
|
|
|
def test_timedelta_type_none():
|
|
assert args.timedelta_type(None) is None
|
|
|
|
|
|
def test_timedelta_type(now):
|
|
expected = datetime.datetime(2014, 1, 15, 10, 10, tzinfo=tz.tzutc())
|
|
with mock.patch(
|
|
'docker_custodian.args.datetime.datetime',
|
|
autospec=True,
|
|
) as mock_datetime:
|
|
mock_datetime.now.return_value = now
|
|
assert args.timedelta_type('5 days') == expected
|