Exemplo n.º 1
0
def test_set_remap_is_scoped():
    lc = LaunchContext()
    push_conf = PushLaunchConfigurations()
    pop_conf = PopLaunchConfigurations()
    set_remap = SetRemap('from', 'to')

    push_conf.execute(lc)
    set_remap.execute(lc)
    assert lc.launch_configurations == {'ros_remaps': [('from', 'to')]}
    pop_conf.execute(lc)
    assert lc.launch_configurations == {}
Exemplo n.º 2
0
def test_set_remap_with_node():
    lc = MockContext()
    node = Node(package='asd',
                executable='bsd',
                name='my_node',
                namespace='my_ns',
                remappings=[('from2', 'to2')])
    set_remap = SetRemap('from1', 'to1')
    set_remap.execute(lc)
    node._perform_substitutions(lc)
    assert len(node.expanded_remapping_rules) == 2
    assert node.expanded_remapping_rules == [('from1', 'to1'),
                                             ('from2', 'to2')]
Exemplo n.º 3
0
def test_set_remap_with_composable_node():
    lc = MockContext()
    node_description = ComposableNode(package='asd',
                                      plugin='my_plugin',
                                      name='my_node',
                                      namespace='my_ns',
                                      remappings=[('from2', 'to2')])
    set_remap = SetRemap('from1', 'to1')
    set_remap.execute(lc)
    request = get_composable_node_load_request(node_description, lc)
    remappings = request.remap_rules
    assert len(remappings) == 2
    assert remappings[0] == 'from1:=to1'
    assert remappings[1] == 'from2:=to2'
Exemplo n.º 4
0
def test_load_node_with_global_remaps_in_group(mock_component_container):
    """Test loading a node with global remaps scoped to a group."""
    context = _assert_launch_no_errors([
        GroupAction(
            [
                SetRemap('chatter', 'new_topic_name'),
                _load_composable_node(
                    package='foo_package',
                    plugin='bar_plugin',
                    name='test_node_name',
                    namespace='test_node_namespace'
                ),
            ],
            scoped=True,
        ),
    ])

    # Check that launch is aware of loaded component
    assert get_node_name_count(context, '/test_node_namespace/test_node_name') == 1

    # Check that container recieved correct request
    assert len(mock_component_container.requests) == 1
    request = mock_component_container.requests[0]
    assert request.package_name == 'foo_package'
    assert request.plugin_name == 'bar_plugin'
    assert request.node_name == 'test_node_name'
    assert request.node_namespace == '/test_node_namespace'
    assert len(request.remap_rules) == 1
    assert request.remap_rules[0] == 'chatter:=new_topic_name'
    assert len(request.parameters) == 0
    assert len(request.extra_arguments) == 0
Exemplo n.º 5
0
def test_set_remap(remapping_rules):
    lc = MockContext()
    for src, dst in remapping_rules:
        SetRemap(src, dst).execute(lc)
    assert lc.launch_configurations == {'ros_remaps': remapping_rules}