From 6b22308914628f6b31c488b6ccb410cc610ab36a Mon Sep 17 00:00:00 2001 From: Thomas Sundvoll Date: Fri, 10 Nov 2023 12:37:22 +0100 Subject: [PATCH] Add tests for inspections --- src/isar_robot/inspections.py | 4 +-- tests/test_inspections.py | 47 ++++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/src/isar_robot/inspections.py b/src/isar_robot/inspections.py index c30a4fda..b0af158a 100644 --- a/src/isar_robot/inspections.py +++ b/src/isar_robot/inspections.py @@ -93,7 +93,7 @@ def create_thermal_video(step: TakeThermalVideo): start_time=now, pose=telemetry.get_pose(), file_type="mp4", - duration=11, + duration=step.duration, ) thermal_video_metadata.tag_id = step.tag_id thermal_video_metadata.analysis_type = ["test1", "test2"] @@ -117,7 +117,7 @@ def create_audio(step: RecordAudio): start_time=now, pose=telemetry.get_pose(), file_type="wav", - duration=11, + duration=step.duration, ) audio_metadata.tag_id = step.tag_id audio_metadata.analysis_type = ["test1", "test2"] diff --git a/tests/test_inspections.py b/tests/test_inspections.py index 70488b05..7e97f42f 100644 --- a/tests/test_inspections.py +++ b/tests/test_inspections.py @@ -1,11 +1,52 @@ from alitra import Frame, Position -from robot_interface.models.mission.step import TakeImage +from robot_interface.models.mission.step import RecordAudio, TakeImage, TakeThermalVideo from isar_robot import inspections +target = Position(x=0, y=0, z=0, frame=Frame("robot")) + def test_create_image(): - target = Position(x=0, y=0, z=0, frame=Frame("robot")) step = TakeImage(target=target) - inspections.create_image(step=step) + list_of_images = inspections.create_image(step) + + assert len(list_of_images) == 1 + + inspection_image = list_of_images[0] + assert inspection_image.metadata.file_type == "jpg" + + +def test_create_video(): + step = TakeImage(target=target) + + list_of_videos = inspections.create_video(step) + + assert len(list_of_videos) == 1 + + inspection_video = list_of_videos[0] + assert inspection_video.metadata.file_type == "mp4" + + +def test_create_thermal_video(): + step = TakeThermalVideo(target=target, duration=10) + + list_of_thermal_videos = inspections.create_thermal_video(step) + + assert len(list_of_thermal_videos) == 1 + + inspection_video = list_of_thermal_videos[0] + assert inspection_video.metadata.file_type == "mp4" + assert inspection_video.metadata.duration == 10 + + +def test_create_audio(): + step = RecordAudio(target=target, duration=10) + + list_of_audio_recordings = inspections.create_audio(step) + + assert len(list_of_audio_recordings) == 1 + + inspection_recordings = list_of_audio_recordings[0] + assert inspection_recordings.metadata.file_type == "wav" + assert inspection_recordings.metadata.duration == 10