@@ -21,21 +21,21 @@ def tearDown(self) -> None:
21
21
os .remove (self .tmpfile .name )
22
22
23
23
def test_import__should_schedule_job (self ):
24
- jobs = list ()
25
- jobs .append (task_factory (TaskType .ONCE , enabled = True , instance_only = True ))
26
- jobs .append (task_factory (TaskType .REPEATABLE , enabled = True , instance_only = True ))
27
- res = json .dumps ([j .to_dict () for j in jobs ])
24
+ tasks = list ()
25
+ tasks .append (task_factory (TaskType .ONCE , enabled = True , instance_only = True ))
26
+ tasks .append (task_factory (TaskType .REPEATABLE , enabled = True , instance_only = True ))
27
+ res = json .dumps ([j .to_dict () for j in tasks ])
28
28
self .tmpfile .write (res )
29
29
self .tmpfile .flush ()
30
30
# act
31
31
call_command ("import" , filename = self .tmpfile .name )
32
32
# assert
33
33
self .assertEqual (1 , Task .objects .filter (task_type = TaskType .ONCE ).count ())
34
34
self .assertEqual (1 , Task .objects .filter (task_type = TaskType .REPEATABLE ).count ())
35
- db_job = Task .objects .filter (task_type = TaskType .ONCE ).first ()
35
+ db_task = Task .objects .filter (task_type = TaskType .ONCE ).first ()
36
36
attrs = ["name" , "queue" , "callable" , "enabled" , "timeout" ]
37
37
for attr in attrs :
38
- self .assertEqual (getattr (jobs [0 ], attr ), getattr (db_job , attr ))
38
+ self .assertEqual (getattr (tasks [0 ], attr ), getattr (db_task , attr ))
39
39
40
40
def test_import__should_schedule_job_yaml (self ):
41
41
tasks = list ()
@@ -49,16 +49,16 @@ def test_import__should_schedule_job_yaml(self):
49
49
# assert
50
50
self .assertEqual (1 , Task .objects .filter (task_type = TaskType .ONCE ).count ())
51
51
self .assertEqual (1 , Task .objects .filter (task_type = TaskType .REPEATABLE ).count ())
52
- db_job = Task .objects .filter (task_type = TaskType .ONCE ).first ()
52
+ task = Task .objects .filter (task_type = TaskType .ONCE ).first ()
53
53
attrs = ["name" , "queue" , "callable" , "enabled" , "timeout" ]
54
54
for attr in attrs :
55
- self .assertEqual (getattr (tasks [0 ], attr ), getattr (db_job , attr ))
55
+ self .assertEqual (getattr (tasks [0 ], attr ), getattr (task , attr ))
56
56
57
57
def test_import__should_schedule_job_yaml_without_yaml_lib (self ):
58
- jobs = list ()
59
- jobs .append (task_factory (TaskType .ONCE , enabled = True , instance_only = True ))
60
- jobs .append (task_factory (TaskType .REPEATABLE , enabled = True , instance_only = True ))
61
- res = yaml .dump ([j .to_dict () for j in jobs ], default_flow_style = False )
58
+ tasks = list ()
59
+ tasks .append (task_factory (TaskType .ONCE , enabled = True , instance_only = True ))
60
+ tasks .append (task_factory (TaskType .REPEATABLE , enabled = True , instance_only = True ))
61
+ res = yaml .dump ([j .to_dict () for j in tasks ], default_flow_style = False )
62
62
self .tmpfile .write (res )
63
63
self .tmpfile .flush ()
64
64
# act
@@ -68,27 +68,27 @@ def test_import__should_schedule_job_yaml_without_yaml_lib(self):
68
68
self .assertEqual (cm .exception .code , 1 )
69
69
70
70
def test_import__should_schedule_job_reset (self ):
71
- jobs = list ()
71
+ tasks = list ()
72
72
task_factory (TaskType .ONCE , enabled = True )
73
73
task_factory (TaskType .ONCE , enabled = True )
74
- jobs .append (task_factory (TaskType .ONCE , enabled = True ))
75
- jobs .append (task_factory (TaskType .REPEATABLE , enabled = True , instance_only = True ))
76
- res = json .dumps ([j .to_dict () for j in jobs ])
74
+ tasks .append (task_factory (TaskType .ONCE , enabled = True ))
75
+ tasks .append (task_factory (TaskType .REPEATABLE , enabled = True , instance_only = True ))
76
+ res = json .dumps ([j .to_dict () for j in tasks ])
77
77
self .tmpfile .write (res )
78
78
self .tmpfile .flush ()
79
79
# act
80
80
call_command ("import" , filename = self .tmpfile .name , reset = True )
81
81
# assert
82
82
self .assertEqual (1 , Task .objects .filter (task_type = TaskType .ONCE ).count ())
83
- db_job = Task .objects .filter (task_type = TaskType .ONCE ).first ()
83
+ task = Task .objects .filter (task_type = TaskType .ONCE ).first ()
84
84
attrs = ["name" , "queue" , "callable" , "enabled" , "timeout" ]
85
85
for attr in attrs :
86
- self .assertEqual (getattr (jobs [0 ], attr ), getattr (db_job , attr ))
86
+ self .assertEqual (getattr (tasks [0 ], attr ), getattr (task , attr ))
87
87
self .assertEqual (1 , Task .objects .filter (task_type = TaskType .REPEATABLE ).count ())
88
- db_job = Task .objects .filter (task_type = TaskType .REPEATABLE ).first ()
88
+ task = Task .objects .filter (task_type = TaskType .REPEATABLE ).first ()
89
89
attrs = ["name" , "queue" , "callable" , "enabled" , "timeout" ]
90
90
for attr in attrs :
91
- self .assertEqual (getattr (jobs [1 ], attr ), getattr (db_job , attr ))
91
+ self .assertEqual (getattr (tasks [1 ], attr ), getattr (task , attr ))
92
92
93
93
def test_import__should_schedule_job_update_existing (self ):
94
94
tasks = list ()
@@ -101,10 +101,10 @@ def test_import__should_schedule_job_update_existing(self):
101
101
call_command ("import" , filename = self .tmpfile .name , update = True )
102
102
# assert
103
103
self .assertEqual (2 , Task .objects .filter (task_type = TaskType .ONCE ).count ())
104
- db_job = Task .objects .filter (task_type = TaskType .ONCE ).get (name = tasks [0 ].name )
104
+ task = Task .objects .filter (task_type = TaskType .ONCE ).get (name = tasks [0 ].name )
105
105
attrs = ["name" , "queue" , "callable" , "enabled" , "timeout" ]
106
106
for attr in attrs :
107
- self .assertEqual (getattr (tasks [0 ], attr ), getattr (db_job , attr ))
107
+ self .assertEqual (getattr (tasks [0 ], attr ), getattr (task , attr ))
108
108
109
109
def test_import__should_schedule_job_without_update_existing (self ):
110
110
tasks = list ()
@@ -117,7 +117,7 @@ def test_import__should_schedule_job_without_update_existing(self):
117
117
call_command ("import" , filename = self .tmpfile .name )
118
118
# assert
119
119
self .assertEqual (2 , Task .objects .filter (task_type = TaskType .ONCE ).count ())
120
- db_job = Task .objects .get (name = tasks [0 ].name )
120
+ task = Task .objects .get (name = tasks [0 ].name )
121
121
attrs = ["id" , "name" , "queue" , "callable" , "enabled" , "timeout" ]
122
122
for attr in attrs :
123
- self .assertEqual (getattr (tasks [0 ], attr ), getattr (db_job , attr ))
123
+ self .assertEqual (getattr (tasks [0 ], attr ), getattr (task , attr ))
0 commit comments