def test_clarify_objects__no_proper_answer__returns_wait_for_response_state(
         self):
     entities = [(EntityType.LOCATION, "blue"),
                 (EntityType.LOCATION, "cover"),
                 (EntityType.OBJECT, "next"),
                 (EntityType.LOCATION, "black"),
                 (EntityType.OBJECT, "bottom cover"),
                 (EntityType.LOCATION, "above"),
                 (EntityType.OBJECT, "bottom cover")]
     grounding_return = GroundingReturn()
     grounding_return.is_success = True
     base_task = Task(name="Dummy name")
     base_task.task_type = TaskType.PICK
     task_grounding_return = TaskGroundingReturn()
     task_grounding_return.task_info.append(base_task)
     self.container.ner.get_entities = Mock(return_value=entities)
     self.container.grounding.find_object = Mock(
         return_value=grounding_return)
     clarify_objects_state = dialog_flow.ClarifyObjects(
         self.state_dict, self.container)
     clarify_objects_state.state_dict["base_task"] = base_task
     clarify_objects_state.state_dict[
         "task_grounding_return"] = task_grounding_return
     clarify_objects_state.is_first_run = False
     self.container.speak = Mock()
     return_state = clarify_objects_state.execute()
     self.assertTrue(
         isinstance(return_state, dialog_flow.WaitForResponseState))
 def test_clarify_objects__cant_find_no_restart_request_grounding_fail_new_error__returns_clarify_state(
         self):
     entities = [(EntityType.LOCATION, "blue"),
                 (EntityType.LOCATION, "cover"),
                 (EntityType.OBJECT, "next"),
                 (EntityType.LOCATION, "black"),
                 (EntityType.OBJECT, "bottom cover"),
                 (EntityType.LOCATION, "above"),
                 (EntityType.OBJECT, "bottom cover")]
     grounding_return = GroundingReturn()
     grounding_return.is_success = False
     grounding_return.error_code = GroundingErrorType.ALREADY_KNOWN
     self.container.ner.get_entities = Mock(return_value=entities)
     self.container.grounding.find_object = Mock(
         return_value=grounding_return)
     clarify_objects_state = dialog_flow.ClarifyObjects(
         self.state_dict, self.container)
     base_task = Task(name="Dummy name")
     dummy_object = ObjectEntity(name="dummy")
     base_task.objects_to_execute_on.append(dummy_object)
     base_task.task_type = TaskType.PICK
     task_grounding_return = TaskGroundingReturn()
     task_grounding_return.task_info.append(base_task)
     clarify_objects_state.state_dict["base_task"] = base_task
     clarify_objects_state.state_dict[
         "task_grounding_return"] = task_grounding_return
     clarify_objects_state.error = GroundingErrorType.CANT_FIND
     clarify_objects_state.is_first_run = False
     self.container.speak = Mock()
     return_state = clarify_objects_state.execute()
     self.assertTrue(isinstance(return_state, dialog_flow.ClarifyObjects))
 def test_clarify_objects__denial_no_restart_request__returns_wait_greet_state(
         self):
     entities = [(EntityType.DENIAL, "blue"), (EntityType.LOCATION,
                                               "cover"),
                 (EntityType.OBJECT, "next"),
                 (EntityType.LOCATION, "black"),
                 (EntityType.OBJECT, "bottom cover"),
                 (EntityType.LOCATION, "above"),
                 (EntityType.OBJECT, "bottom cover")]
     self.container.ner.get_entities = Mock(return_value=entities)
     clarify_objects_state = dialog_flow.ClarifyObjects(
         self.state_dict, self.container)
     clarify_objects_state.error = GroundingErrorType.CANT_FIND
     clarify_objects_state.is_first_run = False
     self.container.speak = Mock()
     return_state = clarify_objects_state.execute()
     self.assertTrue(
         isinstance(return_state, dialog_flow.WaitForGreetingState))
 def test_clarify_objects__first_run_cant_find_object__returns_wait_response_state(
         self):
     clarify_objects_state = dialog_flow.ClarifyObjects(
         self.state_dict, self.container)
     clarify_objects_state.error = GroundingErrorType.CANT_FIND
     self.container.speak = Mock()
     base_task = Task(name="Dummy name")
     dummy_object = ObjectEntity(name="dummy")
     base_task.objects_to_execute_on.append(dummy_object)
     base_task.task_type = TaskType.PICK
     task_grounding_return = TaskGroundingReturn()
     task_grounding_return.task_info.append(base_task)
     clarify_objects_state.state_dict["base_task"] = base_task
     clarify_objects_state.state_dict[
         "task_grounding_return"] = task_grounding_return
     return_state = clarify_objects_state.execute()
     self.assertTrue(
         isinstance(return_state, dialog_flow.WaitForResponseState))