Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 import unittest
00035 import rospkg
00036
00037 import tf
00038 from tf.srv import *
00039
00040
00041 from mock import Mock, MagicMock, patch
00042
00043 from rqt_tf_tree.dotcode_tf import RosTfTreeDotcodeGenerator
00044
00045
00046 class DotcodeGeneratorTest(unittest.TestCase):
00047
00048 def test_generate_dotcode(self):
00049 with patch('tf.TransformListener') as tf:
00050 def tf_srv_fun_mock():
00051 return tf
00052
00053 yaml_data = {'frame1': {'parent': 'fr_parent',
00054 'broadcaster': 'fr_broadcaster',
00055 'rate': 'fr_rate',
00056 'buffer_length': 'fr_buffer_length',
00057 'most_recent_transform': 'fr_most_recent_transform',
00058 'oldest_transform': 'fr_oldest_transform',}}
00059 tf.frame_yaml = str(yaml_data)
00060
00061 factoryMock = Mock()
00062 graphMock = Mock()
00063 timeMock = Mock()
00064 timerMock = Mock()
00065 timerMock.now.return_value=timeMock
00066 timeMock.to_sec.return_value=42
00067
00068 yamlmock = Mock()
00069 yamlmock.load.return_value = yaml_data
00070
00071 factoryMock.create_dot.return_value = "foo"
00072 factoryMock.get_graph.return_value = graphMock
00073
00074 gen = RosTfTreeDotcodeGenerator(0)
00075 graph = gen.generate_dotcode(factoryMock, tf_srv_fun_mock, timerMock)
00076
00077 timerMock.now.assert_called_with()
00078 timeMock.to_sec.assert_called_with()
00079 factoryMock.create_dot.assert_called_with(graphMock)
00080
00081 self.assertEqual(graph, 'foo')