14
14
15
15
import unittest
16
16
17
+ from common import generate_expected_service_report
18
+ from common import generate_expected_topic_report
19
+
17
20
from launch import LaunchDescription
18
21
from launch .actions import ExecuteProcess
19
22
22
25
23
26
import pytest
24
27
25
- from ros2doctor .api import Report
28
+ from ros2doctor .api . service import ServiceReport
26
29
from ros2doctor .api .topic import TopicCheck
27
30
from ros2doctor .api .topic import TopicReport
28
31
29
32
30
33
@pytest .mark .rostest
31
34
@launch_testing .markers .keep_alive
32
- def generate_test_description ():
35
+ def generate_test_description () -> LaunchDescription :
33
36
return LaunchDescription ([
34
37
ExecuteProcess (
35
38
cmd = ['ros2' , 'daemon' , 'stop' ],
@@ -47,14 +50,6 @@ def generate_test_description():
47
50
])
48
51
49
52
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
-
58
53
class TestROS2DoctorAPI (unittest .TestCase ):
59
54
60
55
def test_topic_check (self ):
@@ -64,9 +59,18 @@ def test_topic_check(self):
64
59
self .assertEqual (check_result .error , 0 )
65
60
self .assertEqual (check_result .warning , 0 )
66
61
67
- def test_topic_report (self ):
62
+ def test_no_topic_report (self ):
68
63
"""Assume no topics are publishing or subscribing other than whitelisted ones."""
69
64
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 ])
71
74
self .assertEqual (report .name , expected_report .name )
72
75
self .assertEqual (report .items , expected_report .items )
76
+ self .assertEqual (report , expected_report )
0 commit comments