from datetime import date

from ..period_utils import get_month_shift, get_periods


def test_get_month_shift_handles_december():
    new_month, _ = get_month_shift(12, 1)
    assert 12 == new_month


def test_get_periods_when_end_date_before_period_end():
    # This should produce eight periods, 2 for each of the years from
    # 2015 to 2018 inclusive
    periods = get_periods(date(2015, 01, 01), date(2018, 12, 31), 1, 2)
    assert 8 == len(periods)

@@ -18,16 +18,27 @@
 ort date
+, timedelta
 %0A%0Afrom .
@@ -86,16 +86,35 @@
 _periods
+, periods_intersect
 %0A%0A%0Adef t
@@ -480,8 +480,1175 @@
 eriods)%0A
+%0A%0Adef test_periods_instersect_for_no_second_period():%0A    s = date.today() - timedelta(days=1)%0A    e = date.today() + timedelta(days=1)%0A    assert periods_intersect(s, e, None, None)%0A%0A%0Adef test_periods_intersect_for_when_second_start_date_less_than_first_end_date():%0A    s = date.today() - timedelta(days=1)%0A    e = date.today() + timedelta(days=1)%0A    x = date.today()%0A%0A    assert periods_intersect(s, e, x, None)%0A%0A%0Adef test_periods_intersect_for_when_second_end_date_greater_than_first_start_date():%0A    s = date.today() - timedelta(days=1)%0A    e = date.today() + timedelta(days=1)%0A    y = date.today()%0A%0A    assert periods_intersect(s, e, None, y)%0A%0A%0Adef test_periods_intersect_for_when_second_start_date_in_first_period():%0A    s = date.today() - timedelta(days=1)%0A    e = date.today() + timedelta(days=1)%0A    x = date.today()%0A    y = date.today()%0A%0A    assert periods_intersect(s, e, x, y)%0A%0A%0Adef test_periods_intersect_for_when_period_contains_first_period():%0A    s = date.today() - timedelta(days=1)%0A    e = date.today() + timedelta(days=1)%0A    x = date.today() - timedelta(days=2)%0A    y = date.today() + timedelta(days=2)%0A%0A    assert periods_intersect(s, e, x, y)%0A

Add tests for period_intersect logic