forked from Tivix/django-cron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_crons.py
91 lines (61 loc) · 1.7 KB
/
test_crons.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from time import sleep
from django_cron import CronJobBase, Schedule
class TestSuccessCronJob(CronJobBase):
code = 'test_success_cron_job'
schedule = Schedule(run_every_mins=0)
def do(self):
pass
class TestErrorCronJob(CronJobBase):
code = 'test_error_cron_job'
schedule = Schedule(run_every_mins=0)
def do(self):
raise Exception()
class Test5minsCronJob(CronJobBase):
code = 'test_run_every_mins'
schedule = Schedule(run_every_mins=5)
def do(self):
pass
class Test5minsWithToleranceCronJob(CronJobBase):
code = 'test_run_every_mins'
schedule = Schedule(run_every_mins=5, run_tolerance_seconds=5)
def do(self):
pass
class TestRunAtTimesCronJob(CronJobBase):
code = 'test_run_at_times'
schedule = Schedule(run_at_times=['0:00', '0:05'])
def do(self):
pass
class Wait3secCronJob(CronJobBase):
code = 'test_wait_3_seconds'
schedule = Schedule(run_every_mins=5)
def do(self):
sleep(3)
class RunOnWeekendCronJob(CronJobBase):
code = 'run_on_weekend'
schedule = Schedule(
run_weekly_on_days=[5, 6],
run_at_times=[
'0:00',
],
)
def do(self):
pass
class NoCodeCronJob(CronJobBase):
def do(self):
pass
class RunOnMonthDaysCronJob(CronJobBase):
code = 'run_on_month_days'
schedule = Schedule(
run_monthly_on_days=[1, 10, 20],
run_at_times=[
'0:00',
],
)
def do(self):
pass
class RunEveryMinuteAndRemoveOldLogs(CronJobBase):
code = 'run_and_remove_old_logs'
schedule = Schedule(run_every_mins=1)
remove_successful_cron_logs = True
def do(self):
pass