def test_get_specific_task_from_task__task_is_find__returns_task_with_find(self):
        self.db_mock.get_task = Mock(return_value=(1, "find"))
        task = Task(name="find")
        task.objects_to_execute_on = [ObjectEntity()]

        returned = self.task_grounding.get_specific_task_from_task(task)

        self.assertEqual(TaskType.FIND, returned.task_info[0].task_type)
    def test_get_specific_task_from_task__task_is_custom_task__returns_list_of_primary_skills(self):
        pick_up_task = Task("pick up")
        pick_up_task.task_type = TaskType.PICK
        pick_up_task.objects_to_execute_on = [ObjectEntity()]
        move_task = Task("pick up")
        move_task.task_type = TaskType.MOVE
        move_task.objects_to_execute_on = [ObjectEntity()]
        place_task = Task("pick up")
        place_task.task_type = TaskType.PICK
        place_task.objects_to_execute_on = [ObjectEntity()]
        sub_tasks = [[1, 2, 3], ["pick up", "move", "place"], [pick_up_task, move_task, place_task]]
        tasks = [TaskType.PICK, TaskType.MOVE, TaskType.PLACE]
        self.db_mock.get_task = Mock(return_value=(1, "clear table"))
        self.db_mock.get_sub_tasks = Mock(return_value=sub_tasks)
        task = Task("tidy")

        returned = self.task_grounding.get_specific_task_from_task(task)

        returned_tasks = [returned.task_info[0].task_type,
                          returned.task_info[1].task_type,
                          returned.task_info[2].task_type]

        self.assertEqual(tasks, returned_tasks)
Exemplo n.º 3
0
 def handle_custom_task(self, sub_tasks):
     tasks = []
     for i in range(len(sub_tasks[0])):  # task idx
         task_id = sub_tasks[0][i]
         task_name = sub_tasks[1][i]
         db_task = sub_tasks[2][i]
         task = Task()
         if db_task is not None:
             task.name = task_name
             task.objects_to_execute_on = db_task.objects_to_execute_on
             task.child_tasks = db_task.child_tasks
         sub_task_tasks, error = self.task_switch(task_id, task_name, task)
         tasks.extend(sub_task_tasks)
     return tasks