Extract common testcase class
This commit is contained in:
		
							parent
							
								
									cc3c142f9f
								
							
						
					
					
						commit
						05d60cb57a
					
				
					 9 changed files with 194 additions and 223 deletions
				
			
		| 
						 | 
				
			
			@ -14,40 +14,24 @@
 | 
			
		|||
 | 
			
		||||
import unittest
 | 
			
		||||
 | 
			
		||||
from tracetools_test.utils import (
 | 
			
		||||
    cleanup_trace,
 | 
			
		||||
    get_trace_event_names,
 | 
			
		||||
    run_and_trace,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
BASE_PATH = '/tmp'
 | 
			
		||||
PKG = 'tracetools_test'
 | 
			
		||||
service_callback_events = [
 | 
			
		||||
    'ros2:callback_start',
 | 
			
		||||
    'ros2:callback_end',
 | 
			
		||||
]
 | 
			
		||||
from tracetools_test.case import TraceTestCase
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class TestServiceCallback(unittest.TestCase):
 | 
			
		||||
class TestServiceCallback(TraceTestCase):
 | 
			
		||||
 | 
			
		||||
    def __init__(self, *args) -> None:
 | 
			
		||||
        super().__init__(
 | 
			
		||||
            *args,
 | 
			
		||||
            session_name_prefix='session-test-service-callback',
 | 
			
		||||
            events_ros=[
 | 
			
		||||
                'ros2:callback_start',
 | 
			
		||||
                'ros2:callback_end',
 | 
			
		||||
            ],
 | 
			
		||||
            nodes=['test_service_ping', 'test_service_pong']
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_callback(self):
 | 
			
		||||
        session_name_prefix = 'session-test-service-callback'
 | 
			
		||||
        test_nodes = ['test_service_ping', 'test_service_pong']
 | 
			
		||||
 | 
			
		||||
        exit_code, full_path = run_and_trace(
 | 
			
		||||
            BASE_PATH,
 | 
			
		||||
            session_name_prefix,
 | 
			
		||||
            service_callback_events,
 | 
			
		||||
            None,
 | 
			
		||||
            PKG,
 | 
			
		||||
            test_nodes)
 | 
			
		||||
        self.assertEqual(exit_code, 0)
 | 
			
		||||
 | 
			
		||||
        trace_events = get_trace_event_names(full_path)
 | 
			
		||||
        print(f'trace_events: {trace_events}')
 | 
			
		||||
        self.assertSetEqual(set(service_callback_events), trace_events)
 | 
			
		||||
 | 
			
		||||
        cleanup_trace(full_path)
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue