11"""Tests for ROS2 ActionClient message handling."""
2+
23from unittest .mock import Mock
34
45from roslibpy .comm .comm import RosBridgeProtocol
5- from roslibpy .core import ActionResult , ActionGoalStatus
6+ from roslibpy .core import ActionGoalStatus , ActionResult
67
78
89def test_action_result_with_status_at_top_level ():
@@ -24,10 +25,8 @@ def test_action_result_with_status_at_top_level():
2425 "action" : "/test_action" ,
2526 "id" : request_id ,
2627 "status" : 4 , # SUCCEEDED
27- "values" : {
28- "result" : {"success" : True , "message" : "Action completed" }
29- },
30- "result" : True
28+ "values" : {"result" : {"success" : True , "message" : "Action completed" }},
29+ "result" : True ,
3130 }
3231
3332 protocol ._handle_action_result (message )
@@ -62,9 +61,9 @@ def test_action_result_with_status_in_values():
6261 "id" : request_id ,
6362 "values" : {
6463 "status" : 4 , # SUCCEEDED - status is here instead
65- "result" : {"success" : True , "message" : "Action completed" }
64+ "result" : {"success" : True , "message" : "Action completed" },
6665 },
67- "result" : True
66+ "result" : True ,
6867 }
6968
7069 # This should not raise KeyError
@@ -94,10 +93,8 @@ def test_action_result_failure_with_status_at_top_level():
9493 "action" : "/test_action" ,
9594 "id" : request_id ,
9695 "status" : 6 , # ABORTED
97- "values" : {
98- "result" : {"success" : False , "message" : "Action failed" }
99- },
100- "result" : False
96+ "values" : {"result" : {"success" : False , "message" : "Action failed" }},
97+ "result" : False ,
10198 }
10299
103100 protocol ._handle_action_result (message )
@@ -130,10 +127,8 @@ def test_action_result_without_status_field():
130127 "op" : "action_result" ,
131128 "action" : "/test_action" ,
132129 "id" : request_id ,
133- "values" : {
134- "result" : {"success" : True }
135- },
136- "result" : True
130+ "values" : {"result" : {"success" : True }},
131+ "result" : True ,
137132 }
138133
139134 # Should not raise KeyError, should use default status
0 commit comments