Example #1
0
 def test_tasks(self, tasks):
     """ Test task functions."""
     tasks = Task.get_all()
     assert len(tasks) == 2
     tasks[0].delete()
     tasks = Task.get_all()
     assert len(tasks) == 1
     assert not tasks[0].assigned
Example #2
0
 def test_schedule_tasks(self, tasks, timeperiods):
     """ Test scheduling a task."""
     tps = TimePeriod.get_all()
     tasks = Task.get_all()
     assert tps[0] not in tasks[0].timeperiods
     rt = schedule_task(tasks[0], datetime(2010, 10, 9, 12, 00))
     assert rt == 0
     assert tps[0] in tasks[0].timeperiods
Example #3
0
def schedule_all():
    """ Schedule all tasks."""
    # Get all unassigned tasks
    tasks = Task.get_all()
    errors = list()
    for task in tasks:
        timeleft = schedule_task(task)
        if timeleft > 0:
            errors.append({'task': task, 'timeleft': timeleft})
    return errors
Example #4
0
 def test_assignments(self, tasks, timeperiods):
     """ Check manual assignments."""
     tps = TimePeriod.get_all()
     tasks = Task.get_all()
     assert tps[0].available and tps[1].available
     tps[0].task = tasks[0]
     tps[1].task = tasks[1]
     tps[0].save()
     tps[1].save()
     assert not tps[0].available and not tps[1].available
     assert len(TimePeriod.get_assigned()) == 2
     assert "test1" in tps[0].as_event()['description']
     tasks[0].reset_assignments()
     assert tps[0].available and not tps[1].available