@@ -18,17 +18,38 @@ class TestRepeatableTask(BaseTestCases.TestSchedulableTask):
18
18
19
19
def test_create_task_error (self ):
20
20
scheduled_time = timezone .now ()
21
-
22
- Task .objects .create (
21
+ task = Task .objects .create (
23
22
name = "konichiva_every_2s" ,
24
- callable = "chat.task_scheduler.konichiva_func " ,
25
- task_type = " REPEATABLE" ,
26
- interval = 2 ,
23
+ callable = "scheduler.tests.jobs.test_args_kwargs " ,
24
+ task_type = TaskType . REPEATABLE ,
25
+ interval = 333 ,
27
26
interval_unit = "seconds" ,
28
27
queue = "default" ,
29
28
enabled = True ,
30
29
scheduled_time = scheduled_time ,
31
30
)
31
+ self .assertEqual (task .name , "konichiva_every_2s" )
32
+ self .assertEqual (task .callable , "scheduler.tests.jobs.test_args_kwargs" )
33
+ self .assertEqual (task .task_type , TaskType .REPEATABLE )
34
+ self .assertEqual (task .interval , 333 )
35
+ self .assertEqual (task .interval_unit , "seconds" )
36
+
37
+ def test_create_task_without_scheduled_time (self ):
38
+ task = Task .objects .create (
39
+ name = "konichiva_every_2s" ,
40
+ callable = "scheduler.tests.jobs.test_args_kwargs" ,
41
+ task_type = TaskType .REPEATABLE ,
42
+ interval = 33 ,
43
+ interval_unit = "seconds" ,
44
+ queue = "default" ,
45
+ enabled = True ,
46
+ )
47
+ self .assertAlmostEqual (task .scheduled_time .timestamp (), timezone .now ().timestamp (), delta = 2 )
48
+ self .assertEqual (task .name , "konichiva_every_2s" )
49
+ self .assertEqual (task .callable , "scheduler.tests.jobs.test_args_kwargs" )
50
+ self .assertEqual (task .task_type , TaskType .REPEATABLE )
51
+ self .assertEqual (task .interval , 33 )
52
+ self .assertEqual (task .interval_unit , "seconds" )
32
53
33
54
def test_unschedulable_old_job (self ):
34
55
job = task_factory (self .task_type , scheduled_time = timezone .now () - timedelta (hours = 1 ), repeat = 0 )
@@ -67,16 +88,6 @@ def test_clean_too_frequent(self):
67
88
with self .assertRaises (ValidationError ):
68
89
job .clean_interval_unit ()
69
90
70
- @override_settings (SCHEDULER_CONFIG = SchedulerConfiguration (SCHEDULER_INTERVAL = 10 ))
71
- def test_clean_not_multiple (self ):
72
- job = task_factory (self .task_type )
73
- job .queue = self .queue_name
74
- job .callable = "scheduler.tests.jobs.test_job"
75
- job .interval = 121
76
- job .interval_unit = "seconds"
77
- with self .assertRaises (ValidationError ):
78
- job .clean_interval_unit ()
79
-
80
91
def test_clean_short_result_ttl (self ):
81
92
task = task_factory (self .task_type )
82
93
task .queue = self .queue_name
0 commit comments