def test_perform(): auto = Task("a", auto_task=True, state=BaseTaskState.WORKING) auto.perform(0, seed=1234) assert auto.remaining_work_amount == auto.default_work_amount - 1 task = Task("task") task.state = BaseTaskState.READY w1 = Worker("w1") w2 = Worker("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 = Component("a") c.append_targeted_task(task) task.perform(10) assert task.remaining_work_amount == task.default_work_amount assert task.target_component == c assert c.error == 0.0 task.state = BaseTaskState.WORKING task.perform(10) assert task.remaining_work_amount == task.default_work_amount - 1.0 assert task.target_component == c assert c.error == 0.0 # Next test case w1.workamount_skill_sd_map = {"task": 0.2} w1.quality_skill_mean_map = {"task": 0.9} w1.quality_skill_sd_map = {"task": 0.02} task.perform(11, seed=1234, increase_component_error=2.0) assert task.remaining_work_amount == 7.905712967253502 assert c.error == 2.0
def test_get_quality_skill_point(): """test_get_quality_skill_point.""" w = Worker("w1", "----") # w.set_quality_skill_mean_map( # {"task1": 1.0, "task2": 0.0}, update_other_skill_info=True # ) w.quality_skill_mean_map = {"task1": 1.0, "task2": 0.0} assert w.get_quality_skill_point("task3") == 0.0 assert w.get_quality_skill_point("task2") == 0.0 assert w.get_quality_skill_point("task1") == 1.0 task1 = Task("task1") task1.state = BaseTaskState.NONE w.assigned_task_list = [task1] assert w.get_quality_skill_point("task1") == 1.0 task1.state = BaseTaskState.READY assert w.get_quality_skill_point("task1") == 1.0 task1.state = BaseTaskState.WORKING_ADDITIONALLY assert w.get_quality_skill_point("task1") == 1.0 task1.state = BaseTaskState.FINISHED assert w.get_quality_skill_point("task1") == 1.0 task1.state = BaseTaskState.WORKING assert w.get_quality_skill_point("task1") == 1.0 w.quality_skill_sd_map["task1"] = 0.1 assert w.get_quality_skill_point("task1", seed=1234) == 1.0471435163732492 task2 = Task("task2") task2.state = BaseTaskState.NONE w.assigned_task_list.append(task2) w.quality_skill_sd_map["task1"] = 0.0 assert w.get_quality_skill_point("task1") == 1.0 task2.state = BaseTaskState.WORKING assert w.get_quality_skill_point("task1") == 1.0
def test_has_quality_skill(): w = Worker("w1", "----") # w.set_quality_skill_mean_map( # {"task1": 1.0, "task2": 0.0}, update_other_skill_info=True # ) w.quality_skill_mean_map = {"task1": 1.0, "task2": 0.0} assert w.has_quality_skill("task1") assert not w.has_quality_skill("task2") assert not w.has_quality_skill("task3")