def test_find_topic_name_not_found(self): topic, attr, index = ez_model.find_topic_name('/hoge/data', { '/hogi': 'type_a', '/hoga': 'type_b' }) self.assertEqual(topic, None) self.assertEqual(attr, None) self.assertEqual(index, None)
def test_find_topic_name_found_with_index(self): topic, attr, index = ez_model.find_topic_name('/hoge/data[2]', { '/hoge': 'type_a', '/hoga': 'type_b' }) self.assertEqual(topic, '/hoge') self.assertEqual(attr, ['data']) self.assertEqual(index, 2)
def test_find_topic_name_found_topic_only(self): topic, attr, index = ez_model.find_topic_name('/hoge', { '/hoge': 'type_a', '/hoga': 'type_b' }) self.assertEqual(topic, '/hoge') self.assertEqual(attr, None) self.assertEqual(index, None)
def test_find_topic_name_repeated(self): topic, attr, index = ez_model.find_topic_name('/hoge/goal/goal', { '/hoge/goal': 'type_a', '/hoga': 'type_b' }) self.assertEqual(topic, '/hoge/goal') self.assertEqual(attr, ['goal']) self.assertEqual(index, None)
def test_find_topic_name_found_topic_only_nested_by_nested2(self): topic, attr, index = ez_model.find_topic_name( '/some/topic/again', { '/some/topic/again': 'std_msgs/Float32', '/some/topic': 'std_msgs/Float32', '/this/works': 'std_msgs/Float32' }) self.assertEqual(topic, '/some/topic/again') self.assertEqual(attr, None) self.assertEqual(index, None)