Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def __init__(
# we could check the z distance between entities
# or trust user with this
super().__init__(logger)
if not obj_types:
raise ValueError("obj_types must be a non-empty list")
if allowable_displacement <= 0:
raise ValueError(
f"allowable_displacement must be positive, got {allowable_displacement}"
)
if not set(obj_types).issubset(self.ALLOWED_OBJECTS):
raise TypeError(
f"Invalid obj_types provided: {obj_types}. Allowed objects: {self.ALLOWED_OBJECTS}"
Expand Down
12 changes: 12 additions & 0 deletions tests/rai_bench/manipulation_o3de/tasks/test_build_tower_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ def test_too_big_displacement() -> None:
BuildCubeTowerTask(["red_cube"], allowable_displacement=0.1)


def test_empty_obj_types_raises() -> None:
with pytest.raises(ValueError, match="non-empty"):
BuildCubeTowerTask([])


def test_non_positive_allowable_displacement_raises() -> None:
with pytest.raises(ValueError, match="positive"):
BuildCubeTowerTask(["red_cube"], allowable_displacement=0.0)
with pytest.raises(ValueError, match="positive"):
BuildCubeTowerTask(["red_cube"], allowable_displacement=-0.01)


def test_not_allowable_type() -> None:
with pytest.raises(TypeError):
BuildCubeTowerTask(["red_cube", "apple"], allowable_displacement=0.1)
Loading