def test_minute_back(): rate = Rate('rate(5 minute)') rate.now = datetime(year=2018, month=2, day=11, hour=12, minute=30, second=20) expected = [datetime(year=2018, month=2, day=11, hour=12, minute=25)] assert rate.get_previous() == expected
def test_hours_back_slice(): rate = Rate('rate(2 hours)') rate.now = datetime(year=2018, month=2, day=11, hour=10, minute=30, second=20) expected = [ datetime(year=2018, month=2, day=11, hour=6), datetime(year=2018, month=2, day=11, hour=4), datetime(year=2018, month=2, day=11, hour=2), ] assert rate.get_previous(count=3, start=2) == expected