def test_round_timeblocks_cases_9():
    free_timeslots_raw = [["23:10:00", max_time]]

    expected_rounded_timeblocks_raw = [["23:10:00", max_time]]

    free_timeslots = [[
        f"{time_s_p[0]}{i[0]}{time_s_p[1]}",
        f"{time_s_p[0]}{i[1]}{time_s_p[1]}"
    ] for i in free_timeslots_raw]

    expected_rounded_timeblocks = [[
        f"{time_s_p[0]}{i[0]}{time_s_p[1]}",
        f"{time_s_p[0]}{i[1]}{time_s_p[1]}"
    ] for i in expected_rounded_timeblocks_raw]

    calculated_rounded_timeslots = round_timeblocks(free_timeslots)
    assert calculated_rounded_timeslots == expected_rounded_timeblocks
def test_round_timeblocks_cases_1():
    free_timeslots_raw = [["08:00:00", "12:00:00"], ["12:00:00", max_time]]

    expected_rounded_timeblocks_raw = [
        ["08:00:00", "08:15:00"],
        ["08:15:00", "12:00:00"],
        ["12:00:00", max_time],
    ]

    free_timeslots = [[
        f"{time_s_p[0]}{i[0]}{time_s_p[1]}",
        f"{time_s_p[0]}{i[1]}{time_s_p[1]}"
    ] for i in free_timeslots_raw]

    expected_rounded_timeblocks = [[
        f"{time_s_p[0]}{i[0]}{time_s_p[1]}",
        f"{time_s_p[0]}{i[1]}{time_s_p[1]}"
    ] for i in expected_rounded_timeblocks_raw]

    calculated_rounded_timeslots = round_timeblocks(free_timeslots)
    assert calculated_rounded_timeslots == expected_rounded_timeblocks
scheduled_time_blocks = time_data_dict["scheduled_time_blocks"]
time_min = time_data_dict["time_min"]
time_max = time_data_dict["time_max"]

free_timeblocks = get_free_timeslots(time_min, time_max, scheduled_time_blocks,
                                     DEBUG_MODE)

# Done calculating free time during the day.
# If the first free timeblock is very small (less than 15 mins) then ignore it
# We call this: rounding out the free timeblocks

duration_from_now = (datetime.fromisoformat(free_timeblocks[0][0]) -
                     datetime.fromisoformat(time_min)).total_seconds()
if duration_from_now <= 900:
    rounded_free_timeblocks = round_timeblocks(free_timeblocks)
else:
    rounded_free_timeblocks = free_timeblocks

# Done rounding out the free timeslots
# Now we break up the available time into 1 hour chunks.
# We call this plannable_timeblocks

plannable_timeblocks = break_up_free_timeblocks(rounded_free_timeblocks, 3600,
                                                DEBUG_MODE)

print_time_data("Final result: Current time ", time_min, True, True)
print_time_data("Final result: Blocked time ", scheduled_time_blocks, True,
                True)
print_time_data("Final result: Free time ", rounded_free_timeblocks, True,
                True)