Skip to content

Commit 49d7b71

Browse files
authored
Merge pull request #28 from Unity-Technologies/yamato-test
AIRO-331a Adding smoke tests and Yamato hooks
2 parents 0298729 + 2d47c26 commit 49d7b71

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

.yamato/yamato-config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Endpoint Unit Tests
2+
agent:
3+
type: Unity::VM
4+
image: robotics/ci-ubuntu20:latest
5+
flavor: i1.medium
6+
commands:
7+
- source /opt/ros/noetic/setup.bash && echo "ROS_DISTRO == $ROS_DISTRO" &&
8+
cd .. && mkdir -p catkin_ws/src && cp -r ./ROS-TCP-Endpoint catkin_ws/src &&
9+
cd catkin_ws && catkin_make && source devel/setup.bash && python3 -m pytest
10+
triggers:
11+
cancel_old_ci: true
12+
expression: |
13+
(pull_request.target eq "main" AND
14+
NOT pull_request.push.changes.all match "**/*.md") OR
15+
(push.branch eq "dev" AND
16+
NOT push.changes.all match "**/*.md")

src/ros_tcp_endpoint/subscriber.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(self, topic, message_class, tcp_server, queue_size=10):
3232
message_class: The message class in catkin workspace
3333
queue_size: Max number of entries to maintain in an outgoing queue
3434
"""
35+
RosReceiver.__init__(self)
3536
self.topic = topic
3637
self.node_name = "{}_subscriber".format(topic)
3738
self.msg = message_class

test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

test/test_smoke.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pytest
2+
from unittest import mock
3+
import ros_tcp_endpoint
4+
5+
@mock.patch('ros_tcp_endpoint.publisher.rospy')
6+
def test_pub_constructor(mock_pub_rospy):
7+
mock_msg_pub = mock.Mock()
8+
pub = ros_tcp_endpoint.RosPublisher("/fake_topic", mock_msg_pub)
9+
# Message is constructed in publisher, stored as object instance
10+
mock_msg_pub.assert_called_once()
11+
12+
@mock.patch('ros_tcp_endpoint.subscriber.rospy')
13+
def test_sub_constructor(mock_sub_rospy):
14+
mock_msg_sub = mock.Mock()
15+
sub = ros_tcp_endpoint.RosSubscriber("/fake_topic2", mock_msg_sub, None)
16+
# Message is NOT constructed in subscriber, stored as class reference
17+
mock_msg_sub.assert_not_called()
18+
19+
@mock.patch('ros_tcp_endpoint.service.rospy')
20+
def test_srv_constructor(mock_srv_rospy):
21+
mock_srv = mock.Mock()
22+
src = ros_tcp_endpoint.RosService("fake_service", mock_srv)
23+
mock_srv._request_class.assert_called_once()

0 commit comments

Comments
 (0)