def test_one_day_past_end_date():
    """
    DateRange knows the date after its end date.
    """
    dp = DateRange(start_date="2016-01-07", end_date="2016-01-14")
    assert dp.one_day_past_end_date == dt.datetime(2016, 1, 15, 0, 0, 0)
    assert dp.one_day_past_end_date_as_str == "2016-01-15 00:00:00"

    dp = DateRange(start_date=dt.date(2016, 4, 12),
                   end_date=dt.datetime(2016, 5, 31, 0, 0, 0))
    assert dp.one_day_past_end_date == dt.datetime(2016, 6, 1, 0, 0, 0)
    assert dp.one_day_past_end_date_as_str == "2016-06-01 00:00:00"
def test_start_and_end_date():
    """
    DateRange knows its start and end date,
    """
    dp = DateRange(start_date="2016-01-01", end_date="2016-01-03")
    assert dp.start_date == dt.datetime(2016, 1, 1, 0, 0, 0)
    assert dp.end_date == dt.datetime(2016, 1, 3, 0, 0, 0)
    assert dp.start_date_as_str == "2016-01-01 00:00:00"
    assert dp.end_date_as_str == "2016-01-03 00:00:00"
def test_invalid_start_or_end_dates(expected_error_type, start_date, end_date):
    """
    DateRange knows the date after its end date.
    """
    with pytest.raises(expected_error_type):
        DateRange(start_date=start_date, end_date=end_date)
 def __init__(self, *, metric, start_date, end_date, aggregation_unit):
     assert metric in ["amount", "discount", "fee", "commission"]
     self.metric = metric
     self.date_range = DateRange(start_date, end_date)
     self.aggregation_unit = aggregation_unit
     super().__init__()