Skip to content

Commit

Permalink
Instantiate MockPose member by function
Browse files Browse the repository at this point in the history
  • Loading branch information
sondreo committed Feb 28, 2024
1 parent 2c1903e commit d0ffe21
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/isar/services/readers/test_base_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestBaseReader:
(asdict(MockMissionDefinition.default_mission), Mission),
(asdict(MockStep.drive_to()), Step),
(asdict(MockStep.take_image_in_coordinate_direction()), Step),
(asdict(MockPose.default_pose), Pose),
(asdict(MockPose.default_pose()), Pose),
],
)
def test_dict_to_dataclass(self, dataclass_dict: dict, expected_dataclass: Any):
Expand Down
10 changes: 5 additions & 5 deletions tests/isar/state_machine/test_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def test_reset_state_machine(state_machine) -> None:


def test_state_machine_transitions(injector, state_machine_thread) -> None:
step_1: Step = DriveToPose(pose=MockPose.default_pose)
step_2: Step = TakeImage(target=MockPose.default_pose.position)
step_1: Step = DriveToPose(pose=MockPose.default_pose())
step_2: Step = TakeImage(target=MockPose.default_pose().position)
mission: Mission = Mission(tasks=[Task(steps=[step_1, step_2])]) # type: ignore

scheduling_utilities: SchedulingUtilities = injector.get(SchedulingUtilities)
Expand Down Expand Up @@ -121,8 +121,8 @@ def test_state_machine_transitions_when_running_full_mission(
) -> None:
state_machine_thread.state_machine.stepwise_mission = False

step_1: Step = DriveToPose(pose=MockPose.default_pose)
step_2: Step = TakeImage(target=MockPose.default_pose.position)
step_1: Step = DriveToPose(pose=MockPose.default_pose())
step_2: Step = TakeImage(target=MockPose.default_pose().position)
mission: Mission = Mission(tasks=[Task(steps=[step_1, step_2])]) # type: ignore

scheduling_utilities: SchedulingUtilities = injector.get(SchedulingUtilities)
Expand All @@ -147,7 +147,7 @@ def test_state_machine_transitions_when_running_full_mission(
def test_state_machine_failed_dependency(
injector, state_machine_thread, mocker
) -> None:
drive_to_step: Step = DriveToPose(pose=MockPose.default_pose)
drive_to_step: Step = DriveToPose(pose=MockPose.default_pose())
inspection_step: Step = MockStep.take_image_in_coordinate_direction()
mission: Mission = Mission(tasks=[Task(steps=[drive_to_step, inspection_step])]) # type: ignore

Expand Down
12 changes: 7 additions & 5 deletions tests/mocks/pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@


class MockPose:
default_pose = Pose(
position=Position(x=0, y=0, z=0, frame=Frame("robot")),
orientation=Orientation(x=0, y=0, z=0, w=1, frame=Frame("robot")),
frame=Frame("robot"),
)
@staticmethod
def default_pose():
return Pose(
position=Position(x=0, y=0, z=0, frame=Frame("robot")),
orientation=Orientation(x=0, y=0, z=0, w=1, frame=Frame("robot")),
frame=Frame("robot"),
)
2 changes: 1 addition & 1 deletion tests/mocks/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class MockStep:
@staticmethod
def drive_to() -> DriveToPose:
return DriveToPose(pose=MockPose.default_pose)
return DriveToPose(pose=MockPose.default_pose())

@staticmethod
def take_image_in_coordinate_direction() -> TakeImage:
Expand Down

0 comments on commit d0ffe21

Please sign in to comment.