def test_fresh(self): task = Task(1, 'task_id', 'name', 'job.test', {'args':(), 'kw':{}}, 'every 5') res = task.fresh() assert res == True assert task.task_id is None assert task.status == Task.SCHEDULED assert task.run_times == 1 task = Task(1, 'task_id', 'name', 'job.test', {'args':(), 'kw':{}}, 'every 5') task.event = 'at 20141111 1212' res = task.fresh() assert res == False
def test_event_type(self): t = datetime.now() + timedelta(minutes=5) task = Task(1, 'task_id', 'name', 'job.test', {'args':(), 'kw':{}}, 'at ' + t.strftime('%Y%m%d%H%M')) self.assertEqual(task.event_type, 'at') task.event = 'every 5' self.assertEqual(task.event_type, 'every')