add package rbs_tests (with testing recording demo)
This commit is contained in:
parent
52b0fa5378
commit
e6851c85f1
3 changed files with 89 additions and 0 deletions
12
rbs_tests/CMakeLists.txt
Normal file
12
rbs_tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(rbs_tests)
|
||||||
|
|
||||||
|
find_package(ament_cmake REQUIRED)
|
||||||
|
|
||||||
|
if(BUILD_TESTING)
|
||||||
|
find_package(rbs_utils REQUIRED)
|
||||||
|
find_package(launch_testing_ament_cmake)
|
||||||
|
add_launch_test(integration_tests/integration_tests.py)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ament_package()
|
61
rbs_tests/integration_tests/integration_tests.py
Executable file
61
rbs_tests/integration_tests/integration_tests.py
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# import os
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch, MagicMock
|
||||||
|
|
||||||
|
# import rclpy
|
||||||
|
# from rclpy.executors import SingleThreadedExecutor
|
||||||
|
from rbs_utils.recording_demo import recording_demo, CommandType
|
||||||
|
|
||||||
|
import launch
|
||||||
|
import launch_ros
|
||||||
|
import launch_testing
|
||||||
|
import launch_testing.actions
|
||||||
|
# import launch_testing.asserts
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.mark.rostest
|
||||||
|
def generate_test_description():
|
||||||
|
test_node = launch_ros.actions.Node(
|
||||||
|
package="rbs_bt_executor",
|
||||||
|
executable="rbs_interface.py",
|
||||||
|
output="screen"
|
||||||
|
# parameters = [{"bt_path": skills_cfg_file},{"mode": mode},{"use_sim_time": True}]
|
||||||
|
)
|
||||||
|
|
||||||
|
return launch.LaunchDescription([
|
||||||
|
test_node,
|
||||||
|
launch_testing.actions.ReadyToTest(),
|
||||||
|
]), { 'test_node': test_node }
|
||||||
|
|
||||||
|
class TestRecordingDemo(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# Предполагается, что ROS 2 окружение запущено
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_run_command_returns_bool(self):
|
||||||
|
with patch("rbs_utils.recording_demo.RbsActionClient") as MockClient:
|
||||||
|
mock_client_instance = MockClient.return_value
|
||||||
|
mock_client_instance.res_ok = True
|
||||||
|
mock_client_instance.send_goal = MagicMock()
|
||||||
|
|
||||||
|
result = recording_demo(CommandType.RUN)
|
||||||
|
self.assertTrue(result)
|
||||||
|
mock_client_instance.send_goal.assert_called_with(
|
||||||
|
sid=unittest.mock.ANY, action="RecordingDemo", command="rdConfigure")
|
||||||
|
|
||||||
|
def test_stop_and_cancel_triggers_stop(self):
|
||||||
|
with patch("rbs_utils.recording_demo.RbsActionClient") as MockClient:
|
||||||
|
mock_client_instance = MockClient.return_value
|
||||||
|
mock_client_instance.res_ok = True
|
||||||
|
mock_client_instance.send_goal = MagicMock()
|
||||||
|
|
||||||
|
result = recording_demo(CommandType.STOP_AND_CANCEL)
|
||||||
|
self.assertTrue(result)
|
||||||
|
mock_client_instance.send_goal.assert_called_with(
|
||||||
|
sid=unittest.mock.ANY, action="RecordingDemo", command="rdStop")
|
||||||
|
|
||||||
|
def test_invalid_command_returns_false(self):
|
||||||
|
result = recording_demo("nonexistent_command")
|
||||||
|
self.assertFalse(result)
|
16
rbs_tests/package.xml
Normal file
16
rbs_tests/package.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
|
<package format="3">
|
||||||
|
<name>rbs_tests</name>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<description>Integration tests for the Robossembler-ROS2</description>
|
||||||
|
<maintainer email="shaniks77s@gmail.com">shalenikol</maintainer>
|
||||||
|
<license>Apache-2.0</license>
|
||||||
|
|
||||||
|
<test_depend>launch</test_depend>
|
||||||
|
<test_depend>launch_ros</test_depend>
|
||||||
|
<test_depend>rbs_utils</test_depend>
|
||||||
|
<!-- <test_depend>controller_manager_msgs</test_depend> -->
|
||||||
|
<test_depend>launch_testing_ament_cmake</test_depend>
|
||||||
|
|
||||||
|
</package>
|
Loading…
Add table
Add a link
Reference in a new issue