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 import roslib; roslib.load_manifest('test_roslib')
00033
00034 import os
00035 import struct
00036 import sys
00037 import unittest
00038
00039 import rosunit
00040
00041 class RoslibStackManifestTest(unittest.TestCase):
00042
00043 def _subtest_parse_stack_example1(self, m):
00044 from roslib.manifestlib import _Manifest
00045 self.assert_(isinstance(m, _Manifest))
00046 self.assertEquals('stack', m._type)
00047 self.assertEquals("a brief description", m.brief)
00048 self.assertEquals("Line 1\nLine 2", m.description.strip())
00049 self.assertEquals("The authors\ngo here", m.author.strip())
00050 self.assertEquals("Public Domain\nwith other stuff", m.license.strip())
00051 self.assertEquals("http://ros.org/stack/", m.url)
00052 self.assertEquals("http://www.willowgarage.com/files/willowgarage/robot10.jpg", m.logo)
00053 dpkgs = [d.stack for d in m.depends]
00054 self.assertEquals(set(['stackname', 'common']), set(dpkgs))
00055 self.assertEquals([], m.rosdeps)
00056 self.assertEquals([], m.exports)
00057
00058 def _subtest_parse_stack_version(self, m):
00059 self.assertEquals("1.2.3", m.version)
00060
00061 def test_parse_example1_file(self):
00062 from roslib.stack_manifest import parse_file, StackManifest
00063
00064 p = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'manifest_tests', 'stack_example1.xml')
00065 self._subtest_parse_stack_example1(parse_file(p))
00066
00067 p = os.path.join(roslib.packages.get_pkg_dir('test_roslib'), 'test', 'manifest_tests', 'stack_version.xml')
00068 self._subtest_parse_stack_version(parse_file(p))
00069
00070 def test_parse_example1_string(self):
00071 from roslib.manifestlib import parse, _Manifest
00072 self._subtest_parse_stack_example1(parse(_Manifest('stack'), STACK_EXAMPLE1))
00073
00074 def test_StackManifest(self):
00075 from roslib.stack_manifest import StackManifest
00076 m = StackManifest()
00077 self.assertEquals('stack', m._type)
00078
00079 def test_StackManifest_str(self):
00080
00081 from roslib.stack_manifest import parse
00082 str(parse(STACK_EXAMPLE1))
00083
00084 def test_StackManifest_xml(self):
00085 from roslib.stack_manifest import parse, StackManifest
00086 m = parse(STACK_EXAMPLE1)
00087 self._subtest_parse_stack_example1(m)
00088
00089 m2 = parse(m.xml())
00090 self._subtest_parse_stack_example1(m2)
00091
00092
00093 STACK_EXAMPLE1 = """<stack>
00094 <description brief="a brief description">Line 1
00095 Line 2
00096 </description>
00097 <author>The authors
00098 go here</author>
00099 <license>Public Domain
00100 with other stuff</license>
00101 <url>http://ros.org/stack/</url>
00102 <logo>http://www.willowgarage.com/files/willowgarage/robot10.jpg</logo>
00103 <depend stack="stackname" />
00104 <depend stack="common"/>
00105 </stack>"""
00106
00107 STACK_INVALID1 = """<stack>
00108 <description brief="a brief description">Line 1</description>
00109 <author>The authors</author>
00110 <license>Public Domain</license>
00111 <rosdep name="python" />
00112 </stack>"""
00113
00114 STACK_INVALID2 = """<stack>
00115 <description brief="a brief description">Line 1</description>
00116 <author>The authors</author>
00117 <license>Public Domain</license>
00118 <export>
00119 <cpp cflags="-I${prefix}/include" lflags="-L${prefix}/lib -lros"/>
00120 <cpp os="osx" cflags="-I${prefix}/include" lflags="-L${prefix}/lib -lrosthread -framework CoreServices"/>
00121 </export>
00122 </stack>"""
00123
00124
00125 if __name__ == '__main__':
00126 rosunit.unitrun('test_roslib', 'test_stack_manifest', RoslibStackManifestTest, coverage_packages=['roslib.stack_manifest'])
00127