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
00035
00036 import roslib; roslib.load_manifest('test_roslaunch')
00037
00038 import os, sys, unittest
00039
00040 import rostest
00041 import roslaunch.core
00042 import roslaunch.remote
00043
00044
00045
00046 class TestRoslaunchRemote(unittest.TestCase):
00047
00048
00049 def test_remote_node_xml(self):
00050
00051 Node = roslaunch.core.Node
00052 n = Node('pkg1', 'type1')
00053 self.assertEquals('<node pkg="pkg1" type="type1" ns="/" args="" respawn="False" required="False">\n</node>', n.to_remote_xml())
00054 n = Node('pkg2', 'type2', namespace="/ns2/")
00055 self.assertEquals('<node pkg="pkg2" type="type2" ns="/ns2/" args="" respawn="False" required="False">\n</node>', n.to_remote_xml())
00056
00057 n = Node('pkg3', 'type3', namespace="/ns3/", machine_name="machine3")
00058 self.assertEquals('<node pkg="pkg3" type="type3" ns="/ns3/" args="" respawn="False" required="False">\n</node>', n.to_remote_xml())
00059
00060
00061 n = Node('pkg4', 'type4', args="arg4a arg4b")
00062 self.assertEquals('<node pkg="pkg4" type="type4" ns="/" args="arg4a arg4b" respawn="False" required="False">\n</node>', n.to_remote_xml())
00063
00064 n = Node('pkg5', 'type5', respawn=True)
00065 self.assertEquals('<node pkg="pkg5" type="type5" ns="/" args="" respawn="True" required="False">\n</node>', n.to_remote_xml())
00066 n = Node('pkg6', 'type6', respawn=False)
00067 self.assertEquals('<node pkg="pkg6" type="type6" ns="/" args="" respawn="False" required="False">\n</node>', n.to_remote_xml())
00068
00069 n = Node('pkg6', 'type6', remap_args=[('from6a', 'to6a'), ('from6b', 'to6b')])
00070 self.assertEquals("""<node pkg="pkg6" type="type6" ns="/" args="" respawn="False" required="False">
00071 <remap from="from6a" to="to6a" />
00072 <remap from="from6b" to="to6b" />
00073 </node>""", n.to_remote_xml())
00074
00075 n = Node('pkg7', 'type7', env_args=[('key7a', 'val7a'), ('key7b', 'val7b')])
00076 self.assertEquals("""<node pkg="pkg7" type="type7" ns="/" args="" respawn="False" required="False">
00077 <env name="key7a" value="val7a" />
00078 <env name="key7b" value="val7b" />
00079 </node>""", n.to_remote_xml())
00080
00081 n = Node('pkg8', 'type8', cwd='ros-root')
00082 self.assertEquals('<node pkg="pkg8" type="type8" ns="/" args="" cwd="ros-root" respawn="False" required="False">\n</node>', n.to_remote_xml())
00083 n = Node('pkg9', 'type9', cwd='node')
00084 self.assertEquals('<node pkg="pkg9" type="type9" ns="/" args="" cwd="node" respawn="False" required="False">\n</node>', n.to_remote_xml())
00085
00086 n = Node('pkg10', 'type10', output='screen')
00087 self.assertEquals('<node pkg="pkg10" type="type10" ns="/" args="" output="screen" respawn="False" required="False">\n</node>', n.to_remote_xml())
00088 n = Node('pkg11', 'type11', output='log')
00089 self.assertEquals('<node pkg="pkg11" type="type11" ns="/" args="" output="log" respawn="False" required="False">\n</node>', n.to_remote_xml())
00090
00091
00092 n = Node('pkg12', 'type12', launch_prefix='xterm -e')
00093 self.assertEquals('<node pkg="pkg12" type="type12" ns="/" args="" respawn="False" launch-prefix="xterm -e" required="False">\n</node>', n.to_remote_xml())
00094
00095
00096 n = Node('pkg13', 'type13', required=True)
00097 self.assertEquals('<node pkg="pkg13" type="type13" ns="/" args="" respawn="False" required="True">\n</node>', n.to_remote_xml())
00098
00099
00100 n = Node('pkg20', 'type20', namespace="/ns20/", machine_name="foo", remap_args=[('from20a', 'to20a'), ('from20b', 'to20b')], env_args=[('key20a', 'val20a'), ('key20b', 'val20b')], output="screen", cwd="ros-root", respawn=True, args="arg20a arg20b", launch_prefix="nice", required=False)
00101 self.assertEquals("""<node pkg="pkg20" type="type20" ns="/ns20/" args="arg20a arg20b" output="screen" cwd="ros-root" respawn="True" launch-prefix="nice" required="False">
00102 <remap from="from20a" to="to20a" />
00103 <remap from="from20b" to="to20b" />
00104 <env name="key20a" value="val20a" />
00105 <env name="key20b" value="val20b" />
00106 </node>""", n.to_remote_xml())
00107
00108 def test_remote_test_node_xml(self):
00109 Test = roslaunch.core.Test
00110
00111
00112 Test = roslaunch.core.Test
00113 n = Test('test1', 'pkg1', 'type1')
00114 self.assertEquals('<test pkg="pkg1" type="type1" ns="/" args="" output="log" required="False" test-name="test1">\n</test>', n.to_remote_xml())
00115 n = Test('test2', 'pkg2', 'type2', namespace="/ns2/")
00116 self.assertEquals('<test pkg="pkg2" type="type2" ns="/ns2/" args="" output="log" required="False" test-name="test2">\n</test>', n.to_remote_xml())
00117
00118 n = Test('test3', 'pkg3', 'type3', namespace="/ns3/", machine_name="machine3")
00119 self.assertEquals('<test pkg="pkg3" type="type3" ns="/ns3/" args="" output="log" required="False" test-name="test3">\n</test>', n.to_remote_xml())
00120
00121
00122 n = Test('test4', 'pkg4', 'type4', args="arg4a arg4b")
00123 self.assertEquals('<test pkg="pkg4" type="type4" ns="/" args="arg4a arg4b" output="log" required="False" test-name="test4">\n</test>', n.to_remote_xml())
00124
00125 n = Test('test6', 'pkg6', 'type6', remap_args=[('from6a', 'to6a'), ('from6b', 'to6b')])
00126 self.assertEquals("""<test pkg="pkg6" type="type6" ns="/" args="" output="log" required="False" test-name="test6">
00127 <remap from="from6a" to="to6a" />
00128 <remap from="from6b" to="to6b" />
00129 </test>""", n.to_remote_xml())
00130
00131 n = Test('test7', 'pkg7', 'type7', env_args=[('key7a', 'val7a'), ('key7b', 'val7b')])
00132 self.assertEquals("""<test pkg="pkg7" type="type7" ns="/" args="" output="log" required="False" test-name="test7">
00133 <env name="key7a" value="val7a" />
00134 <env name="key7b" value="val7b" />
00135 </test>""", n.to_remote_xml())
00136
00137 n = Test('test8', 'pkg8', 'type8', cwd='ros-root')
00138 self.assertEquals('<test pkg="pkg8" type="type8" ns="/" args="" output="log" cwd="ros-root" required="False" test-name="test8">\n</test>', n.to_remote_xml())
00139 n = Test('test9', 'pkg9', 'type9', cwd='node')
00140 self.assertEquals('<test pkg="pkg9" type="type9" ns="/" args="" output="log" cwd="node" required="False" test-name="test9">\n</test>', n.to_remote_xml())
00141
00142
00143 n = Test('test20', 'pkg20', 'type20', namespace="/ns20/", machine_name="foo", remap_args=[('from20a', 'to20a'), ('from20b', 'to20b')], env_args=[('key20a', 'val20a'), ('key20b', 'val20b')], cwd="ros-root", args="arg20a arg20b")
00144 self.assertEquals("""<test pkg="pkg20" type="type20" ns="/ns20/" args="arg20a arg20b" output="log" cwd="ros-root" required="False" test-name="test20">
00145 <remap from="from20a" to="to20a" />
00146 <remap from="from20b" to="to20b" />
00147 <env name="key20a" value="val20a" />
00148 <env name="key20b" value="val20b" />
00149 </test>""", n.to_remote_xml())
00150
00151 if __name__ == '__main__':
00152 rostest.unitrun('test_roslaunch', sys.argv[0], TestRoslaunchRemote, coverage_packages=['roslaunch.remote'])
00153