Ejemplo n.º 1
0
def test_streak_of_5_days_dates_out_of_order():
    data = """
    +------------+------------+---------+
    | date       | activity   | count   |
    |------------+------------+---------|
    | 2018-11-11 | pcc        | 1       |
    | 2018-11-07 | pcc        | 1       |
    | 2018-11-09 | 100d       | 2       |
    | 2018-11-10 | 100d       | 1       |
    | 2018-11-08 | pcc        | 1       |
    +------------+------------+---------+
    """
    dates = extract_dates(data)
    streak = calculate_streak(dates)
    assert streak == 5
Ejemplo n.º 2
0
def test_streak_of_3_days():
    data = """
    +------------+------------+---------+
    | date       | activity   | count   |
    |------------+------------+---------|
    | 2018-11-12 | pcc        | 1       |
    | 2018-11-11 | 100d       | 1       |
    | 2018-11-10 | 100d       | 2       |
    | 2018-10-15 | pcc        | 1       |
    | 2018-10-15 | pcc        | 1       |
    | 2018-10-05 | bite       | 1       |
    | 2018-09-21 | bite       | 4       |
    | 2018-09-18 | bite       | 2       |
    | 2018-09-16 | bite       | 4       |
    +------------+------------+---------+
    """
    dates = extract_dates(data)
    streak = calculate_streak(dates)
    assert streak == 3
Ejemplo n.º 3
0
def test_streak_of_1_day_thanks_to_todays_progress():
    data = """
    +------------+------------+---------+
    | date       | activity   | count   |
    |------------+------------+---------|
    | 2018-11-12 | pcc        | 1       |
    | 2018-11-09 | 100d       | 1       |
    | 2018-11-07 | 100d       | 2       |
    | 2018-10-15 | pcc        | 1       |
    | 2018-10-15 | pcc        | 1       |
    | 2018-10-05 | bite       | 1       |
    | 2018-09-21 | bite       | 4       |
    | 2018-09-18 | bite       | 2       |
    | 2018-09-16 | bite       | 4       |
    +------------+------------+---------+
    """
    dates = extract_dates(data)
    streak = calculate_streak(dates)
    assert streak == 1
Ejemplo n.º 4
0
def test_streak_of_1_day_can_still_make_today():
    data = """
    +------------+------------+---------+
    | date       | activity   | count   |
    |------------+------------+---------|
    | 2018-11-11 | pcc        | 1       |
    | 2018-11-09 | 100d       | 1       |
    | 2018-11-07 | 100d       | 2       |
    | 2018-10-23 | pcc        | 1       |
    | 2018-10-15 | pcc        | 1       |
    | 2018-10-05 | bite       | 1       |
    | 2018-09-21 | bite       | 4       |
    | 2018-09-18 | bite       | 2       |
    | 2018-09-18 | bite       | 4       |
    +------------+------------+---------+
    """
    dates = extract_dates(data)
    streak = calculate_streak(dates)
    assert streak == 1
Ejemplo n.º 5
0
def test_streak_of_almost_10_days_but_gap_so_only_5_days():
    data = """
    +------------+------------+---------+
    | date       | activity   | count   |
    |------------+------------+---------|
    | 2018-11-11 | pcc        | 1       |
    | 2018-11-10 | 100d       | 1       |
    | 2018-11-09 | 100d       | 2       |
    | 2018-11-08 | pcc        | 1       |
    | 2018-11-07 | pcc        | 1       |
    | 2018-11-05 | bite       | 4       |
    | 2018-11-04 | bite       | 2       |
    | 2018-11-03 | bite       | 4       |
    | 2018-11-02 | 100d       | 2       |
    +------------+------------+---------+
    """
    dates = extract_dates(data)
    streak = calculate_streak(dates)
    assert streak == 5