Example #1
0
def test_perform():
    """test_perform."""
    task = BaseTask("task")
    task.state = BaseTaskState.WORKING
    w1 = BaseWorker("w1")
    w2 = BaseWorker("w2")
    w1.workamount_skill_mean_map = {"task": 1.0}
    task.allocated_worker_list = [w1, w2]
    w1.assigned_task_list = [task]
    w2.assigned_task_list = [task]
    c = BaseComponent("a")
    c.append_targeted_task(task)
    auto_task = BaseTask("auto", auto_task=True)
    auto_task.state = BaseTaskState.WORKING
    w = BaseWorkflow([task, auto_task])
    w.perform(10)
    assert task.remaining_work_amount == task.default_work_amount - 1.0
    assert auto_task.remaining_work_amount == auto_task.default_work_amount - 1.0
    assert task.target_component == c

    # autotask testing
    w.initialize()
    task.state = BaseTaskState.WORKING
    auto_task.state = BaseTaskState.WORKING
    w.perform(10, only_auto_task=True)
    assert task.remaining_work_amount == task.default_work_amount
    assert auto_task.remaining_work_amount == auto_task.default_work_amount - 1.0
Example #2
0
def test_initialize():
    task = BaseTask("task")
    task.est = 2.0
    task.eft = 10.0
    task.lst = 3.0
    task.lft = 11.0
    task.remaining_work_amount = 7
    task.actual_work_amount = 6
    task.state = BaseTaskState.FINISHED
    task.ready_time_list = [1]
    task.start_time_list = [2]
    task.finish_time_list = [15]
    task.additional_task_flag = True
    task.allocated_worker_list = [BaseResource("w1")]

    task_after1 = BaseTask("task_after1")
    task_after2 = BaseTask("task_after2", default_work_amount=5.0)
    task_after1.append_input_task(task)
    task_after2.append_input_task(task)

    w = BaseWorkflow([task, task_after1, task_after2])
    w.critical_path_length = 100.0
    w.initialize()
    assert w.critical_path_length == 20.0
    assert w.task_list[0].est == 0.0
    assert w.task_list[0].eft == 10.0
    assert w.task_list[0].lst == 0.0
    assert w.task_list[0].lft == 10.0
    assert w.task_list[0].state == BaseTaskState.READY
    assert w.task_list[1].est == 10.0
    assert w.task_list[1].eft == 20.0
    assert w.task_list[1].lst == 10.0
    assert w.task_list[1].lft == 20.0
    assert w.task_list[1].state == BaseTaskState.NONE
    assert w.task_list[2].est == 10.0
    assert w.task_list[2].eft == 15.0
    assert w.task_list[2].lst == 15.0
    assert w.task_list[2].lft == 20.0
    assert w.task_list[2].state == BaseTaskState.NONE