def test_method_callable(self, mock): tm = TaskManager(skills=self.skill_generator()) tm.ongoingTasks = [Skill()] tm.execute_mission() self.assertTrue(mock.called)
def test_correct_task_action_client_called(self, mock): tm = TaskManager(skills=[self.skill_generator()]) task1 = GenericSkill(skillName='example-skill', skillType='GenericSkill', skillClass='GenericSkill', allowedSkillPropertiesKeys=[ 'exampleSkillProperty0', 'exampleSkillProperty0' ], skillProperties={ 'exampleSkillProperty0': 'exampleSkillValue0', 'exampleSkillProperty1': 'exampleSkillValue1' }) tm.ongoingTasks = [task1] tm.execute_mission('fakeMissionId') self.assertTrue(mock.called)
def test_multiple_generic_skills(self): skills = ROSInterface.get_ROS_param(self.skillsParamName) task1 = GenericSkill(skillName = 'example-skill', skillType = 'GenericSkill', skillClass = 'GenericSkill', allowedSkillPropertiesKeys = ['exampleSkillProperty0', 'exampleSkillProperty0'], skillProperties = {'exampleSkillProperty0': 'exampleSkillValue0', 'exampleSkillProperty1': 'exampleSkillValue1'}) tm = TaskManager(robotId = 'testRobotId', skills = skills) tm.ongoingTasks = [task1, task1, task1] result = tm.execute_mission('fakeMissionId') self.assertEquals(tm.missions[0]['statusCode'], 11) self.assertEquals(tm.missions[0]['taskId'], 'example-skill')
def test_generic_skill_execution_timeout_while_waiting_for_action_response(self): skills = ROSInterface.get_ROS_param(self.skillsParamName) task1 = GenericSkill(skillName = 'example-skill', skillType = 'GenericSkill', skillClass = 'GenericSkill', allowedSkillPropertiesKeys = ['exampleSkillProperty0', 'exampleSkillProperty0'], skillProperties = {'exampleSkillProperty0': 'exampleSkillValue0', 'exampleSkillProperty1': 'exampleSkillValue1'}) tm = TaskManager(robotId = 'testRobotId', skills = skills, waitForActionClientTimeOut = 0.5) tm.ongoingTasks = [task1] result = tm.execute_mission('fakeMissionId') self.assertEquals(tm.missions[0]['statusCode'], 12) self.assertEquals(tm.missions[0]['taskId'], 'example-skill') self.assertEquals(tm.missions[0]['statusDescription'], 'Mission Failed! Task example-skill Failed: Skill Action Client Error: Timed out (0.5s) while waiting for GenericSkill Action Server result')
def test_wait_skill_execution_timeout_while_waiting_for_server(self): skills = ROSInterface.get_ROS_param(self.skillsParamName) task1 = GenericSkill(skillName = 'crob-wait', skillType = 'WaitSkill', skillClass = 'GenericSkill', allowedSkillPropertiesKeys = ['waitTime'], skillProperties = {'waitTime': 5}) tm = TaskManager(robotId = 'testRobotId', skills = skills, waitForServerTimeOut = 2) tm.ongoingTasks = [task1] result = tm.execute_mission('fakeMissionId') self.assertEquals(tm.missions[0]['statusCode'], 12) self.assertEquals(tm.missions[0]['taskId'], 'crob-wait') self.assertEquals(tm.missions[0]['statusDescription'], 'Mission Failed! Task crob-wait Failed: Skill Action Client Error: Timed out (2s) while trying to find Action Server WaitSkill')
def test_mix_between_correct_and_incorrect_skills(self): skills = ROSInterface.get_ROS_param(self.skillsParamName) task1 = GenericSkill(skillName = 'example-skill', skillType = 'GenericSkill', skillClass = 'GenericSkill', allowedSkillPropertiesKeys = ['exampleSkillProperty0', 'exampleSkillProperty0'], skillProperties = {'exampleSkillProperty0': 'exampleSkillValue0', 'exampleSkillProperty1': 'exampleSkillValue1'}) task2 = GenericSkill(skillName = 'crob-wait', skillType = 'WaitSkill', skillClass = 'GenericSkill', allowedSkillPropertiesKeys = ['waitTime'], skillProperties = {'waitTime': 5}) tm = TaskManager(robotId = 'testRobotId', skills = skills, waitForServerTimeOut = 2) tm.ongoingTasks = [task1, task2, task1] result = tm.execute_mission('fakeMissionId') self.assertEquals(tm.missions[0]['statusCode'], 12) self.assertEquals(tm.missions[0]['taskId'], 'crob-wait') self.assertEquals(tm.missions[0]['statusDescription'], 'Mission Failed! Task crob-wait Failed: Skill Action Client Error: Timed out (2s) while trying to find Action Server WaitSkill')