import pytest
from apps.process.utils import get_audio_parts ,get_sec, generate_name
from datetime import datetime


@pytest.mark.parametrize("part_list,expect_list",
                         [([[1200, 1400], [2300, 2600], [3200, 3400], [4200, 4800], [5100, 5300]],
                         [[0, 1200], [1200, 1400], [1400, 2300], [2300, 2600], [2600, 3200],
                         [3200, 3400], [3400, 4200], [4200, 4800], [4800, 5100], [5100, 5300],
                         [5300, 9000]]), ([[1, 2], [3, 4], [5, 6]], [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5],
                         [5, 6], [6, 9000]])])

def test_get_audio_part_with_multi_parts(part_list,expect_list) -> None:
    assert get_audio_parts(9000, part_list) == expect_list

# @pytest.mark.skip(reason='Because not valid')
@pytest.mark.parametrize("part_list,expect", [([[1, 2]], [[0, 1],[1, 2], [2, 9000]])])
def test_get_audio_with_one_part(part_list, expect) -> None:
    assert get_audio_parts(9000, part_list) == expect


@pytest.mark.parametrize("seconds,expected_ms", [('00:00:02', 2000), ('00:00:30', 30000), ('00:01:09', 69000)])
def test_second_to_ms(seconds: str, expected_ms: int) -> None:
    assert get_sec(seconds) == expected_ms


@pytest.mark.xfail()
def test_wrong_time_format() -> None: # sepose to fail
    assert get_sec("01:01") == 69000

