Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_inspection #172

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/isar_robot/inspections.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def create_image(task_actions: Union[TakeImage, TakeThermalImage]):
filepath: Path = random.choice(list(example_images.iterdir()))
image.data = _read_data_from_file(filepath)

return [image]
return image


def create_video(task_actions: TakeVideo):
Expand All @@ -76,7 +76,7 @@ def create_video(task_actions: TakeVideo):
filepath: Path = random.choice(list(example_videos.iterdir()))
video.data = _read_data_from_file(filepath)

return [video]
return video


def create_thermal_video(task_actions: TakeThermalVideo):
Expand All @@ -96,7 +96,7 @@ def create_thermal_video(task_actions: TakeThermalVideo):
filepath: Path = random.choice(list(example_thermal_videos.iterdir()))
thermal_video.data = _read_data_from_file(filepath)

return [thermal_video]
return thermal_video


def create_audio(task_actions: RecordAudio):
Expand All @@ -116,7 +116,7 @@ def create_audio(task_actions: RecordAudio):
filepath: Path = random.choice(list(example_thermal_videos.iterdir()))
audio.data = _read_data_from_file(filepath)

return [audio]
return audio


def _read_data_from_file(filename: Path) -> bytes:
Expand Down
24 changes: 6 additions & 18 deletions tests/test_inspections.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,32 @@
def test_create_image():
task_actions = TakeImage(target=target)

list_of_images = inspections.create_image(task_actions)
inspection_image = inspections.create_image(task_actions)

assert len(list_of_images) == 1

inspection_image = list_of_images[0]
assert inspection_image.metadata.file_type == "jpg"


def test_create_video():
task_actions = TakeImage(target=target)

list_of_videos = inspections.create_video(task_actions)

assert len(list_of_videos) == 1
inspection_video = inspections.create_video(task_actions)

inspection_video = list_of_videos[0]
assert inspection_video.metadata.file_type == "mp4"


def test_create_thermal_video():
task_actions = TakeThermalVideo(target=target, duration=10)

list_of_thermal_videos = inspections.create_thermal_video(task_actions)
inspection_video = inspections.create_thermal_video(task_actions)

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():
task_actions = RecordAudio(target=target, duration=10)

list_of_audio_recordings = inspections.create_audio(task_actions)

assert len(list_of_audio_recordings) == 1
inspection_recording = inspections.create_audio(task_actions)

inspection_recordings = list_of_audio_recordings[0]
assert inspection_recordings.metadata.file_type == "wav"
assert inspection_recordings.metadata.duration == 10
assert inspection_recording.metadata.file_type == "wav"
assert inspection_recording.metadata.duration == 10