Skip to content

Commit

Permalink
Fill out action goal request population tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sea-bass committed Nov 2, 2023
1 parent b434598 commit 5ac1783
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ def test_execute_advertised_action(self):
self.assertEqual(self.received_message["op"], "action_result")
self.assertEqual(self.received_message["values"]["result"]["sequence"], [0, 1, 1, 2, 3, 5])

@unittest.skip("Currently fails in Iron/Rolling CI, need to fix this")
def test_cancel_advertised_action(self):
@unittest.skip(
reason="Currently fails in Iron/Rolling due to https://github.com/ros2/rclpy/issues/1195, need to fix this"
)
def test_cancel_advertised_action(self):
# Advertise the action
action_path = "/fibonacci_action_3"
advertise_msg = loads(
Expand Down
30 changes: 25 additions & 5 deletions rosbridge_library/test/internal/actions/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from rosbridge_library.internal import actions
from rosbridge_library.internal import message_conversion as c
from rosbridge_library.internal import ros_loader
from rosbridge_library.internal.message_conversion import FieldTypeMismatchException


class ActionTester:
Expand Down Expand Up @@ -109,15 +110,34 @@ def msgs_equal(self, msg1, msg2):

def test_populate_goal_args(self):
# Test empty messages
for srv_type in ["TestEmpty", "TestFeedbackAndResult", "TestResultOnly"]:
cls = ros_loader.get_action_class("rosbridge_test_msgs/" + srv_type)
for action_type in ["TestEmpty", "TestFeedbackAndResult", "TestResultOnly"]:
cls = ros_loader.get_action_class("rosbridge_test_msgs/" + action_type)
for args in [[], {}, None]:
# Should throw no exceptions
actions.args_to_action_goal_instance("", cls.Goal(), args)

# TODO: Test actions with data message

# TODO: Test actions with multiple fields
# Test actions with data message
for action_type in ["TestGoalOnly", "TestGoalAndResult", "TestGoalFeedbackAndResult"]:
cls = ros_loader.get_action_class("rosbridge_test_msgs/" + action_type)
for args in [[3], {"data": 3}]:
# Should throw no exceptions
actions.args_to_action_goal_instance("", cls.Goal(), args)
self.assertRaises(
FieldTypeMismatchException,
actions.args_to_action_goal_instance,
"",
cls.Goal(),
["hello"],
)

# Test actions with multiple fields
cls = ros_loader.get_action_class("rosbridge_test_msgs/TestMultipleGoalFields")
for args in [
[3, 3.5, "hello", False],
{"int_value": 3, "float_value": 3.5, "string": "hello", "bool_value": False},
]:
# Should throw no exceptions
actions.args_to_action_goal_instance("", cls.Goal(), args)

def test_send_action_goal(self):
"""Test a simple action call"""
Expand Down
4 changes: 4 additions & 0 deletions rosbridge_test_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ rosidl_generate_interfaces(${PROJECT_NAME}
srv/TestResponseOnly.srv
action/TestEmpty.action
action/TestFeedbackAndResult.action
action/TestGoalAndResult.action
action/TestGoalFeedbackAndResult.action
action/TestGoalOnly.action
action/TestMultipleGoalFields.action
action/TestResultOnly.action
DEPENDENCIES builtin_interfaces geometry_msgs std_msgs
)
Expand Down
7 changes: 7 additions & 0 deletions rosbridge_test_msgs/action/TestGoalAndResult.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Goal
int32 data
---
# Empty feedback
---
# result
int32 data
8 changes: 8 additions & 0 deletions rosbridge_test_msgs/action/TestGoalFeedbackAndResult.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Goal
int32 data
---
# Feedback
int32 data
---
# result
int32 data
6 changes: 6 additions & 0 deletions rosbridge_test_msgs/action/TestGoalOnly.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Goal
int32 data
---
# Empty feedback
---
# Empty result
9 changes: 9 additions & 0 deletions rosbridge_test_msgs/action/TestMultipleGoalFields.action
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Goal
int32 int_value
float32 float_value
string string
bool bool_value
---
# Empty feedback
---
# Empty result

0 comments on commit 5ac1783

Please sign in to comment.