-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_string_to_seconds.py
53 lines (46 loc) · 1.04 KB
/
test_string_to_seconds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from string_to_seconds import all_to_seconds, check_data_format
import pytest
@pytest.mark.parametrize(
"value, expected",
[
("01:00:01", 3601),
("00:01:00", 60),
("10:00:00", 36000),
("00:00:00", 0),
("23:59:59", 86399),
],
)
def test_valid_input(value, expected):
assert all_to_seconds(value) == expected
@pytest.mark.parametrize(
"value",
[
"",
"second",
"hours:00:00",
"00:minutes:00",
"00:00:seconds",
"25:01:01",
"01:61:01",
"01:01:61",
"01:01:01:01",
"01:01:01 Second",
"01 :01 :01 :01",
"01:01:01:::::",
],
)
def test_invalid_strings_raise_value_error(value):
with pytest.raises(ValueError):
check_data_format(value)
@pytest.mark.parametrize(
"value",
[
"24:60:60",
"23:59:60",
"23:60:59",
"23:60:-1",
],
)
def test_all_to_seconds_raises_value_error(value):
with pytest.raises(ValueError):
all_to_seconds(value)