1414
1515import unittest
1616
17+ from common import generate_expected_service_report
18+ from common import generate_expected_topic_report
19+
1720from launch import LaunchDescription
1821from launch .actions import ExecuteProcess
1922
2225
2326import pytest
2427
25- from ros2doctor .api import Report
28+ from ros2doctor .api . service import ServiceReport
2629from ros2doctor .api .topic import TopicCheck
2730from ros2doctor .api .topic import TopicReport
2831
2932
3033@pytest .mark .rostest
3134@launch_testing .markers .keep_alive
32- def generate_test_description ():
35+ def generate_test_description () -> LaunchDescription :
3336 return LaunchDescription ([
3437 ExecuteProcess (
3538 cmd = ['ros2' , 'daemon' , 'stop' ],
@@ -47,14 +50,6 @@ def generate_test_description():
4750 ])
4851
4952
50- def _generate_expected_report (topic , pub_count , sub_count ):
51- expected_report = Report ('TOPIC LIST' )
52- expected_report .add_to_report ('topic' , topic )
53- expected_report .add_to_report ('publisher count' , pub_count )
54- expected_report .add_to_report ('subscriber count' , sub_count )
55- return expected_report
56-
57-
5853class TestROS2DoctorAPI (unittest .TestCase ):
5954
6055 def test_topic_check (self ):
@@ -64,9 +59,18 @@ def test_topic_check(self):
6459 self .assertEqual (check_result .error , 0 )
6560 self .assertEqual (check_result .warning , 0 )
6661
67- def test_topic_report (self ):
62+ def test_no_topic_report (self ):
6863 """Assume no topics are publishing or subscribing other than whitelisted ones."""
6964 report = TopicReport ().report ()
70- expected_report = _generate_expected_report ('none' , 0 , 0 )
65+ expected_report = generate_expected_topic_report ('none' , 0 , 0 )
66+ self .assertEqual (report .name , expected_report .name )
67+ self .assertEqual (report .items , expected_report .items )
68+ self .assertEqual (report , expected_report )
69+
70+ def test_no_service_report (self ):
71+ """Assume no services are being used other than whitelisted ones."""
72+ report = ServiceReport ().report ()
73+ expected_report = generate_expected_service_report (['none' ], [0 ], [0 ])
7174 self .assertEqual (report .name , expected_report .name )
7275 self .assertEqual (report .items , expected_report .items )
76+ self .assertEqual (report , expected_report )
0 commit comments