-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathtest_cron.py
More file actions
54 lines (48 loc) · 1.17 KB
/
test_cron.py
File metadata and controls
54 lines (48 loc) · 1.17 KB
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
54
"""Test Cron."""
# external
import pytest
# local
from validators import ValidationError, cron
@pytest.mark.parametrize(
"value",
[
"* * * * *",
"*/5 * * * *",
"0 0 * * *",
"30 3 * * 1-5",
"15 5 * * 1,3,5",
"0 12 1 */2 *",
"0 */3 * * *",
"0 0 1 1 *",
"0 12 * 1-6 1-5",
"0 3-6 * * *",
"*/15 0,6,12,18 * * *",
"0 12 * * 0",
"*/61 * * * *",
# "5-10/2 * * * *", # this is valid, but not supported yet
],
)
def test_returns_true_on_valid_cron(value: str):
"""Test returns true on valid cron string."""
assert cron(value)
@pytest.mark.parametrize(
"value",
[
"* * * * * *",
"* * * *",
"*/5 25 * * *",
"*/5 * *-1 * *",
"32-30 * * * *",
"0 12 32 * *",
"0 12 * * 8",
"0 */0 * * *",
"30-20 * * * *",
"10-* * * * *",
"*/15 0,6,12,24 * * *",
"& * * & * *",
"* - * * - *",
],
)
def test_returns_failed_validation_on_invalid_cron(value: str):
"""Test returns failed validation on invalid cron string."""
assert isinstance(cron(value), ValidationError)