Example #1
0
    def test_parse_command_map_unknown_type(self):
        # Same as above, use an unknown message type
        topic = 'unknown_type'
        topic_type_str = self.topics_and_types[topic]
        commands = self.params[topic]
        ret = LanguageToMessageTranslator.parse_command_mapping(
            topic, topic_type_str, commands)

        self.assertIsNotNone(ret)
        self.assertEqual({}, ret)
Example #2
0
    def test_parse_command_map_basic(self):
        # Turn the commands defined in 'basic_topic' into a command mapping.
        topic = 'basic_topic'
        topic_type_str = self.topics_and_types[topic]
        commands = self.params[topic]
        ret = LanguageToMessageTranslator.parse_command_mapping(
            topic, topic_type_str, commands)

        self.assertIsNotNone(ret)

        # Should have the same number of elements as commands.
        self.assertEqual(len(commands), len(ret))

        for cmd in commands:  # All commands are in the map
            self.assertIn(cmd, ret)
            # Inspect each tuple: (topic, message)
            x = ret[cmd]
            self.assertEqual(2, len(x))
            self.assertEqual(topic, x[0])
            self.assertIsInstance(x[1], genpy.Message)
            self.assertIsInstance(x[1], std_msgs.msg.String)

        self.assertEqual('output', ret['input'][1].data)
        self.assertEqual('output with spaces', ret['input with spaces'][1].data)
Example #3
0
 def test_parse_command_map_wrong_type(self):
     not_a_type = 'NotAType'
     ret = LanguageToMessageTranslator.parse_command_mapping(
         'topic_name', not_a_type, {'a': 'b'})
     self.assertIsNotNone(ret)