39 from mock
import Mock, patch
47 with patch(
'tf2_ros.TransformListener')
as tf:
48 def tf_srv_fun_mock():
51 yaml_data = {
'frame1': {
'parent':
'fr_parent',
52 'broadcaster':
'fr_broadcaster',
54 'buffer_length':
'fr_buffer_length',
55 'most_recent_transform':
'fr_most_recent_transform',
56 'oldest_transform':
'fr_oldest_transform',}}
57 tf.frame_yaml = str(yaml_data)
63 timerMock.now.return_value = timeMock
64 timeMock.to_sec.return_value = 42
67 yamlmock.load.return_value = yaml_data
69 factoryMock.create_dot.return_value =
"foo" 70 factoryMock.get_graph.return_value = graphMock
73 graph = gen.generate_dotcode(factoryMock, tf_srv_fun_mock, timerMock)
75 timerMock.now.assert_called_with()
76 timeMock.to_sec.assert_called_with()
77 factoryMock.create_dot.assert_called_with(graphMock)
79 self.assertEqual(graph,
'foo')
81 if __name__ ==
'__main__':
def test_generate_dotcode(self)