Skip to content

Commit

Permalink
move start_end_from_daterange tests to a class
Browse files Browse the repository at this point in the history
  • Loading branch information
geier committed Apr 14, 2024
1 parent 9511393 commit c78595c
Showing 1 changed file with 39 additions and 37 deletions.
76 changes: 39 additions & 37 deletions tests/controller_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,40 +143,42 @@ def test_mix_datetime_types(self, coll_vdirs):
utils.BERLIN.localize(dt.datetime(2015, 6, 2, 16, 0))


def test_start_end():
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 11, 0, 0)
assert (start, end) == start_end_from_daterange(('today',), locale=utils.LOCALE_BERLIN)


def test_start_end_default_delta():
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 11, 0, 0)
assert (start, end) == start_end_from_daterange(('today',), utils.LOCALE_BERLIN)


def test_start_end_delta():
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 12, 0, 0)
assert (start, end) == start_end_from_daterange(('today', '2d'), utils.LOCALE_BERLIN)


def test_start_end_empty():
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 11, 0, 0)
assert (start, end) == start_end_from_daterange([], utils.LOCALE_BERLIN)


def test_start_end_empty_default():
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 13, 0, 0)
assert (start, end) == start_end_from_daterange(
[], utils.LOCALE_BERLIN,
default_timedelta_date=dt.timedelta(days=3),
default_timedelta_datetime=dt.timedelta(hours=1),
)
class TestStartEndFromDaterange:
def test_start_end(self):
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 11, 0, 0)
assert (start, end) == start_end_from_daterange(('today',), locale=utils.LOCALE_BERLIN)


def test_start_end_default_delta(self):
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 11, 0, 0)
assert (start, end) == start_end_from_daterange(('today',), utils.LOCALE_BERLIN)


def test_start_end_delta(self):
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 12, 0, 0)
assert (start, end) == start_end_from_daterange(('today', '2d'), utils.LOCALE_BERLIN)


def test_start_end_empty(self):
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 11, 0, 0)
assert (start, end) == start_end_from_daterange([], utils.LOCALE_BERLIN)


def test_start_end_empty_default(self):
with freeze_time('2016-04-10'):
start = dt.datetime(2016, 4, 10, 0, 0)
end = dt.datetime(2016, 4, 13, 0, 0)
assert (start, end) == start_end_from_daterange(
[], utils.LOCALE_BERLIN,
default_timedelta_date=dt.timedelta(days=3),
default_timedelta_datetime=dt.timedelta(hours=1),
)

0 comments on commit c78595c

Please sign in to comment.