Example #1
0
def test_Node():
    from roslaunch.core import Node

    n = Node("package", "node_type")
    assert n.package == "package"
    assert n.type == "node_type"
    assert n.xmltype() == "node"
    assert n.xmlattrs() == [
        ("pkg", "package"),
        ("type", "node_type"),
        ("machine", None),
        ("ns", "/"),
        ("args", ""),
        ("output", None),
        ("cwd", None),
        ("respawn", False),
        ("respawn_delay", 0.0),
        ("name", None),
        ("launch-prefix", None),
        ("required", False),
    ], n.xmlattrs()
    assert n.output == None

    # tripwire for now
    n.to_xml()
    val = n.to_remote_xml()
    assert "machine" not in val

    # test bad constructors
    try:
        n = Node("package", "node_type", cwd="foo")
        assert False
    except ValueError:
        pass
    try:
        n = Node("package", "node_type", output="foo")
        assert False
    except ValueError:
        pass
    try:
        n = Node("package", "")
        assert False
    except ValueError:
        pass
    try:
        n = Node("", "node_type")
        assert False
    except ValueError:
        pass
    try:
        n = Node("package", "node_type", name="ns/node")
        assert False
    except ValueError:
        pass
    try:
        n = Node("package", "node_type", respawn=True, required=True)
        assert False
    except ValueError:
        pass
Example #2
0
def test_Node():
    from roslaunch.core import Node
    n = Node('package', 'node_type')
    assert n.package == 'package'
    assert n.type == 'node_type'
    assert n.xmltype() == 'node'
    assert n.xmlattrs() == [('pkg', 'package'), ('type', 'node_type'),
                            ('machine', None), ('ns', '/'), ('args', ''),
                            ('output', None), ('cwd', None),
                            ('respawn', False), ('name', None),
                            ('launch-prefix', None),
                            ('required', False)], n.xmlattrs()
    assert n.output == None

    #tripwire for now
    n.to_xml()
    val = n.to_remote_xml()
    assert 'machine' not in val

    # test bad constructors
    try:
        n = Node('package', 'node_type', cwd='foo')
        assert False
    except ValueError:
        pass
    try:
        n = Node('package', 'node_type', output='foo')
        assert False
    except ValueError:
        pass
    try:
        n = Node('package', '')
        assert False
    except ValueError:
        pass
    try:
        n = Node('', 'node_type')
        assert False
    except ValueError:
        pass
    try:
        n = Node('package', 'node_type', name='ns/node')
        assert False
    except ValueError:
        pass
    try:
        n = Node('package', 'node_type', respawn=True, required=True)
        assert False
    except ValueError:
        pass
def test_Node():
    from roslaunch.core import Node
    n = Node('package', 'node_type')
    assert n.package == 'package'
    assert n.type == 'node_type'
    assert n.xmltype() == 'node'
    assert n.xmlattrs() == [('pkg', 'package'), ('type', 'node_type'), ('machine', None), ('ns', '/'), ('args', ''), ('output', None), ('cwd', None), ('respawn', False), ('name', None), ('launch-prefix', None), ('required', False)], n.xmlattrs()
    assert n.output == None

    #tripwire for now
    n.to_xml()
    val = n.to_remote_xml()
    assert 'machine' not in val
    
    # test bad constructors
    try:
        n = Node('package', 'node_type', cwd='foo')
        assert False
    except ValueError:
        pass
    try:
        n = Node('package', 'node_type', output='foo')
        assert False
    except ValueError:
        pass
    try:
        n = Node('package', '')
        assert False
    except ValueError:
        pass
    try:
        n = Node('', 'node_type')
        assert False
    except ValueError:
        pass
    try:
        n = Node('package', 'node_type', name='ns/node')
        assert False
    except ValueError:
        pass
    try:
        n = Node('package', 'node_type', respawn=True, required=True)
        assert False
    except ValueError:
        pass