1010from scheduler .models import ScheduledTask , RepeatableTask , Task
1111from scheduler .queues import get_queue
1212from scheduler .tests .jobs import failing_job , test_job
13- from scheduler .tests .testtools import task_factory
13+ from scheduler .tests .testtools import task_factory , old_task_factory
1414from . import test_settings # noqa
1515from .test_views import BaseTestCase
1616from ..models .task import TaskType
@@ -167,8 +167,8 @@ def tearDown(self) -> None:
167167
168168 def test_export__should_export_job (self ):
169169 jobs = list ()
170- jobs .append (task_factory (ScheduledTask , enabled = True ))
171- jobs .append (task_factory (RepeatableTask , enabled = True ))
170+ jobs .append (task_factory (TaskType . ONCE , enabled = True ))
171+ jobs .append (task_factory (TaskType . REPEATABLE , enabled = True ))
172172
173173 # act
174174 call_command ("export" , filename = self .tmpfile .name )
@@ -180,8 +180,8 @@ def test_export__should_export_job(self):
180180
181181 def test_export__should_export_enabled_jobs_only (self ):
182182 jobs = list ()
183- jobs .append (task_factory (ScheduledTask , enabled = True ))
184- jobs .append (task_factory (RepeatableTask , enabled = False ))
183+ jobs .append (task_factory (TaskType . ONCE , enabled = True ))
184+ jobs .append (task_factory (TaskType . REPEATABLE , enabled = False ))
185185
186186 # act
187187 call_command ("export" , filename = self .tmpfile .name , enabled = True )
@@ -192,8 +192,8 @@ def test_export__should_export_enabled_jobs_only(self):
192192
193193 def test_export__should_export_job_yaml_without_yaml_lib (self ):
194194 jobs = list ()
195- jobs .append (task_factory (ScheduledTask , enabled = True ))
196- jobs .append (task_factory (RepeatableTask , enabled = True ))
195+ jobs .append (task_factory (TaskType . ONCE , enabled = True ))
196+ jobs .append (task_factory (TaskType . REPEATABLE , enabled = True ))
197197
198198 # act
199199 with mock .patch .dict ("sys.modules" , {"yaml" : None }):
@@ -203,8 +203,8 @@ def test_export__should_export_job_yaml_without_yaml_lib(self):
203203
204204 def test_export__should_export_job_yaml_green (self ):
205205 jobs = list ()
206- jobs .append (task_factory (ScheduledTask , enabled = True ))
207- jobs .append (task_factory (RepeatableTask , enabled = True ))
206+ jobs .append (task_factory (TaskType . ONCE , enabled = True ))
207+ jobs .append (task_factory (TaskType . REPEATABLE , enabled = True ))
208208
209209 # act
210210 call_command ("export" , filename = self .tmpfile .name , format = "yaml" )
@@ -224,8 +224,8 @@ def tearDown(self) -> None:
224224
225225 def test_import__should_schedule_job (self ):
226226 jobs = list ()
227- jobs .append (task_factory (ScheduledTask , enabled = True , instance_only = True ))
228- jobs .append (task_factory (RepeatableTask , enabled = True , instance_only = True ))
227+ jobs .append (task_factory (TaskType . ONCE , enabled = True , instance_only = True ))
228+ jobs .append (task_factory (TaskType . REPEATABLE , enabled = True , instance_only = True ))
229229 res = json .dumps ([j .to_dict () for j in jobs ])
230230 self .tmpfile .write (res )
231231 self .tmpfile .flush ()
@@ -241,8 +241,8 @@ def test_import__should_schedule_job(self):
241241
242242 def test_import__should_schedule_job_yaml (self ):
243243 tasks = list ()
244- tasks .append (task_factory (ScheduledTask , enabled = True , instance_only = True ))
245- tasks .append (task_factory (RepeatableTask , enabled = True , instance_only = True ))
244+ tasks .append (task_factory (TaskType . ONCE , enabled = True , instance_only = True ))
245+ tasks .append (task_factory (TaskType . REPEATABLE , enabled = True , instance_only = True ))
246246 res = yaml .dump ([j .to_dict () for j in tasks ], default_flow_style = False )
247247 self .tmpfile .write (res )
248248 self .tmpfile .flush ()
@@ -258,8 +258,8 @@ def test_import__should_schedule_job_yaml(self):
258258
259259 def test_import__should_schedule_job_yaml_without_yaml_lib (self ):
260260 jobs = list ()
261- jobs .append (task_factory (ScheduledTask , enabled = True , instance_only = True ))
262- jobs .append (task_factory (RepeatableTask , enabled = True , instance_only = True ))
261+ jobs .append (task_factory (TaskType . ONCE , enabled = True , instance_only = True ))
262+ jobs .append (task_factory (TaskType . REPEATABLE , enabled = True , instance_only = True ))
263263 res = yaml .dump ([j .to_dict () for j in jobs ], default_flow_style = False )
264264 self .tmpfile .write (res )
265265 self .tmpfile .flush ()
@@ -271,10 +271,10 @@ def test_import__should_schedule_job_yaml_without_yaml_lib(self):
271271
272272 def test_import__should_schedule_job_reset (self ):
273273 jobs = list ()
274- task_factory (ScheduledTask , enabled = True )
275- task_factory (ScheduledTask , enabled = True )
276- jobs .append (task_factory (ScheduledTask , enabled = True ))
277- jobs .append (task_factory (RepeatableTask , enabled = True , instance_only = True ))
274+ task_factory (TaskType . ONCE , enabled = True )
275+ task_factory (TaskType . ONCE , enabled = True )
276+ jobs .append (task_factory (TaskType . ONCE , enabled = True ))
277+ jobs .append (task_factory (TaskType . REPEATABLE , enabled = True , instance_only = True ))
278278 res = json .dumps ([j .to_dict () for j in jobs ])
279279 self .tmpfile .write (res )
280280 self .tmpfile .flush ()
@@ -298,8 +298,8 @@ def test_import__should_schedule_job_reset(self):
298298
299299 def test_import__should_schedule_job_update_existing (self ):
300300 tasks = list ()
301- tasks .append (task_factory (ScheduledTask , enabled = True ))
302- tasks .append (task_factory (ScheduledTask , enabled = True ))
301+ tasks .append (task_factory (TaskType . ONCE , enabled = True ))
302+ tasks .append (task_factory (TaskType . ONCE , enabled = True ))
303303 res = json .dumps ([j .to_dict () for j in tasks ])
304304 self .tmpfile .write (res )
305305 self .tmpfile .flush ()
@@ -318,8 +318,8 @@ def test_import__should_schedule_job_update_existing(self):
318318
319319 def test_import__should_schedule_job_without_update_existing (self ):
320320 tasks = list ()
321- tasks .append (task_factory (ScheduledTask , enabled = True ))
322- tasks .append (task_factory (ScheduledTask , enabled = True ))
321+ tasks .append (task_factory (TaskType . ONCE , enabled = True ))
322+ tasks .append (task_factory (TaskType . ONCE , enabled = True ))
323323 res = json .dumps ([j .to_dict () for j in tasks ])
324324 self .tmpfile .write (res )
325325 self .tmpfile .flush ()
0 commit comments