21 lines
459 B
Python
21 lines
459 B
Python
|
|
import pytest
|
||
|
|
|
||
|
|
from app.core.duration import parse_iso8601_duration
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize(
|
||
|
|
"value,expected",
|
||
|
|
[
|
||
|
|
("PT18M42S", 18 * 60 + 42),
|
||
|
|
("PT1H2M3S", 3600 + 120 + 3),
|
||
|
|
("PT45S", 45),
|
||
|
|
("PT5M", 300),
|
||
|
|
("P1DT2H", 86400 + 7200),
|
||
|
|
(None, None),
|
||
|
|
("", None),
|
||
|
|
("garbage", None),
|
||
|
|
],
|
||
|
|
)
|
||
|
|
def test_parse_iso8601_duration(value, expected):
|
||
|
|
assert parse_iso8601_duration(value) == expected
|