@@ -63,6 +63,16 @@ def test_recorder_services_list_argument(test_arguments_parser):
6363 assert output_path .as_posix () == args .output
6464
6565
66+ def test_recorder_actions_list_argument (test_arguments_parser ):
67+ """Test recorder --actions list argument parser."""
68+ output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
69+ args = test_arguments_parser .parse_args (
70+ ['--actions' , 'action1' , 'action2' , '--output' , output_path .as_posix ()]
71+ )
72+ assert ['action1' , 'action2' ] == args .actions
73+ assert output_path .as_posix () == args .output
74+
75+
6676def test_recorder_services_and_positional_topics_list_arguments (test_arguments_parser ):
6777 """Test recorder --services list and positional topics list arguments parser."""
6878 output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
@@ -74,6 +84,17 @@ def test_recorder_services_and_positional_topics_list_arguments(test_arguments_p
7484 assert output_path .as_posix () == args .output
7585
7686
87+ def test_recorder_actions_and_positional_topics_list_arguments (test_arguments_parser ):
88+ """Test recorder --actions list and positional topics list arguments parser."""
89+ output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
90+ args = test_arguments_parser .parse_args (
91+ ['--output' , output_path .as_posix (),
92+ '--actions' , 'action1' , 'action2' , '--' , 'topic1' , 'topic2' ])
93+ assert ['action1' , 'action2' ] == args .actions
94+ assert ['topic1' , 'topic2' ] == args .topics_positional
95+ assert output_path .as_posix () == args .output
96+
97+
7798def test_recorder_services_and_optional_topics_list_arguments (test_arguments_parser ):
7899 """Test recorder --services list and optional --topics list arguments parser."""
79100 output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
@@ -85,6 +106,41 @@ def test_recorder_services_and_optional_topics_list_arguments(test_arguments_par
85106 assert output_path .as_posix () == args .output
86107
87108
109+ def test_recorder_actions_and_optional_topics_list_arguments (test_arguments_parser ):
110+ """Test recorder --actions list and optional --topics list arguments parser."""
111+ output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
112+ args = test_arguments_parser .parse_args (
113+ ['--output' , output_path .as_posix (),
114+ '--actions' , 'action1' , 'action2' , '--topics' , 'topic1' , 'topic2' ])
115+ assert ['action1' , 'action2' ] == args .actions
116+ assert ['topic1' , 'topic2' ] == args .topics
117+ assert output_path .as_posix () == args .output
118+
119+
120+ def test_recorder_services_and_actions_list_arguments (test_arguments_parser ):
121+ """Test recorder --services list and --actions list arguments parser."""
122+ output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
123+ args = test_arguments_parser .parse_args (
124+ ['--output' , output_path .as_posix (),
125+ '--services' , 'service1' , 'service2' , '--actions' , 'action1' , 'action2' ])
126+ assert ['service1' , 'service2' ] == args .services
127+ assert ['action1' , 'action2' ] == args .actions
128+ assert output_path .as_posix () == args .output
129+
130+
131+ def test_recorder_services_actions_and_topics_list_arguments (test_arguments_parser ):
132+ """Test recorder --services list, --actions list and --topics list arguments parser."""
133+ output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
134+ args = test_arguments_parser .parse_args (
135+ ['--output' , output_path .as_posix (),
136+ '--services' , 'service1' , 'service2' , '--actions' , 'action1' , 'action2' ,
137+ '--topics' , 'topic1' , 'topic2' ])
138+ assert ['service1' , 'service2' ] == args .services
139+ assert ['action1' , 'action2' ] == args .actions
140+ assert ['topic1' , 'topic2' ] == args .topics
141+ assert output_path .as_posix () == args .output
142+
143+
88144def test_recorder_topic_types_list_argument (test_arguments_parser ):
89145 """Test recorder --topic-types list argument parser."""
90146 output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
@@ -124,6 +180,16 @@ def test_recorder_exclude_services_list_argument(test_arguments_parser):
124180 assert output_path .as_posix () == args .output
125181
126182
183+ def test_recorder_exclude_actions_list_argument (test_arguments_parser ):
184+ """Test recorder --exclude-actions list argument parser."""
185+ output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
186+ args = test_arguments_parser .parse_args (
187+ ['--exclude-actions' , 'action1' , 'action2' , '--output' , output_path .as_posix ()]
188+ )
189+ assert ['action1' , 'action2' ] == args .exclude_actions
190+ assert output_path .as_posix () == args .output
191+
192+
127193def test_recorder_custom_data_list_argument (test_arguments_parser ):
128194 """Test recorder --custom-data list argument parser."""
129195 output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
@@ -138,21 +204,22 @@ def test_recorder_validate_exclude_regex_needs_inclusive_args(test_arguments_par
138204 """Test that --exclude-regex needs inclusive arguments."""
139205 output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
140206 args = test_arguments_parser .parse_args (
141- ['--exclude-regex' , '%s-%s' , '--services' , 'service1' , '--topics' , 'topic1' ,
142- '--output' , output_path .as_posix ()]
207+ ['--exclude-regex' , '%s-%s' , '--services' , 'service1' , '--topics' , 'topic1' , '--actions' ,
208+ 'action1' , ' --output' , output_path .as_posix ()]
143209 )
144210 assert '%s-%s' == args .exclude_regex
145211 assert args .all is False
146212 assert args .all_topics is False
147213 assert [] == args .topic_types
148214 assert args .all_services is False
215+ assert args .all_actions is False
149216 assert '' == args .regex
150217
151218 uri = args .output or datetime .datetime .now ().strftime ('rosbag2_%Y_%m_%d-%H_%M_%S' )
152219 error_str = validate_parsed_arguments (args , uri )
153220 assert error_str is not None
154221 expected_output = '--exclude-regex argument requires either --all, ' \
155- '--all-topics, --topic-types, --all-services or --regex'
222+ '--all-topics, --topic-types, --all-services, --all-actions or --regex'
156223 matches = expected_output in error_str
157224 assert matches , ERROR_STRING_MSG .format (expected_output , error_str )
158225
@@ -227,3 +294,26 @@ def test_recorder_validate_exclude_services_needs_inclusive_args(test_arguments_
227294 'or --regex'
228295 matches = expected_output in error_str
229296 assert matches , ERROR_STRING_MSG .format (expected_output , error_str )
297+
298+
299+ def test_recorder_validate_exclude_actions_needs_inclusive_args (test_arguments_parser ):
300+ """Test that --exclude-actions needs at least --all, --all-actions or --regex arguments."""
301+ output_path = RESOURCES_PATH / 'ros2bag_tmp_file'
302+ args = test_arguments_parser .parse_args (
303+ ['--exclude-actions' , 'action1' , '--actions' , 'action1' , '--all-topics' ,
304+ '--output' , output_path .as_posix ()]
305+ )
306+ assert ['action1' ] == args .exclude_actions
307+ assert args .all is False
308+ assert args .all_topics is True
309+ assert [] == args .topic_types
310+ assert args .all_services is False
311+ assert '' == args .regex
312+ assert '' == args .exclude_regex
313+
314+ uri = args .output or datetime .datetime .now ().strftime ('rosbag2_%Y_%m_%d-%H_%M_%S' )
315+ error_str = validate_parsed_arguments (args , uri )
316+ assert error_str is not None
317+ expected_output = '--exclude-actions argument requires either --all, --all-actions or --regex'
318+ matches = expected_output in error_str
319+ assert matches , ERROR_STRING_MSG .format (expected_output , error_str )
0 commit comments