34 import roslib; roslib.load_manifest(PKG)
48 s1 = {
'/chatter':
'std_msgs/String'}
49 p1 = {
'/chatter':
'std_msgs/String'}
50 i1 = Interface(s1, p1)
51 self.assertEquals(i1, i1)
52 self.assertEquals(s1, i1.subscribed_topics)
53 self.assertEquals(s1, i1.published_topics)
55 i2 = Interface({
'/chatter':
'std_msgs/String'}, {
'/chatter':
'std_msgs/String'})
56 self.assertEquals(i1, i2)
57 i3 = Interface({
'/chatter2':
'std_msgs/String'}, {
'/chatter':
'std_msgs/String'})
58 self.assertNotEquals(i1, i3)
59 i4 = Interface({
'/chatter':
'std_msgs/String'}, {
'/chatter2':
'std_msgs/String'})
60 self.assertNotEquals(i1, i4)
64 c1 = Client(client_type=
"android",
65 manager_data={
"manager1":
"dataA"},
66 app_data={
"app1":
"dataB"})
67 self.assertEquals(
"android", c1.client_type)
68 self.assertEquals({
"manager1":
"dataA"}, c1.manager_data)
69 self.assertEquals({
"app1":
"dataB"}, c1.app_data)
70 self.assertEquals(c1, c1)
71 c2 = Client(client_type=
"android",
72 manager_data={
"manager1":
"dataA"},
73 app_data={
"app1":
"dataB"})
74 self.assertEquals(c1, c2)
76 Client(
"androidB", {
"manager1":
"dataA"},
78 Client(
"android", {
"manager2":
"dataA"},
80 Client(
"android", {
"manager1":
"dataA"},
84 self.assertNotEquals(c1, c3)
89 ad1 = AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})])
90 self.assertEquals(ad1, ad1)
91 ad2 = AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})])
92 self.assertEquals(ad1, ad2)
93 ad3 = AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})],
None)
94 self.assertEquals(ad1, ad3)
96 ad1b = AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})],
'app_manager/icon.png')
97 self.assertEquals(ad1, ad1)
98 ad2b = AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})],
'app_manager/icon.png')
99 self.assertEquals(ad1b, ad2b)
100 nad2b = AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})],
'app_manager/icon2.png')
101 self.assertNotEquals(ad1, nad2b)
104 AppDefinition(
'bar',
'Foo',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})]),
105 AppDefinition(
'foo',
'Bar',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})]),
106 AppDefinition(
'foo',
'Foo',
'Is Bar',
'android',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})]),
107 AppDefinition(
'foo',
'Foo',
'Is Foo',
'ios',
'foo.launch',
'foo.interface', [Client(
"android", {}, {})]),
108 AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'bar.launch',
'foo.interface', [Client(
"android", {}, {})]),
109 AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'foo.launch',
'bar.interface', [Client(
"android", {}, {})]),
110 AppDefinition(
'foo',
'Foo',
'Is Foo',
'android',
'foo.launch',
'foo.interface', [Client(
"ios", {}, {})]),
113 self.assertNotEquals(ad1, nad)
117 rospack = rospkg.RosPack()
118 path = rospack.get_path(PKG)
119 test_dir = os.path.join(path,
'test')
121 e = os.path.join(test_dir,
'empty.interface')
122 self.assertEquals(e,
find_resource(
'%s/empty.interface'%(PKG)))
124 e = os.path.join(test_dir,
'applist1',
'apps1.installed')
125 self.assertEquals(e,
find_resource(
'%s/apps1.installed'%(PKG)))
129 self.fail(
"should have thrown ValueError: no package name")
134 self.fail(
"should have thrown ValueError: no resource name")
139 rospack = rospkg.RosPack()
140 rl_dir = rospack.get_path(
'roslaunch')
141 from app_manager
import NotFoundException, InternalAppException
145 self.fail(
"should fail")
146 except ValueError:
pass 149 self.fail(
"should fail")
150 except NotFoundException:
pass 153 self.assertEquals(
"app_manager/appA", ad.name)
154 self.assertEquals(
"Android Joystick", ad.display_name)
155 self.assertEquals(
"Control the TurtleBot with an Android device", ad.description)
156 self.assertEquals(
"turtlebot", ad.platform)
158 self.assertEquals(os.path.join(rospack.get_path(PKG),
'test',
'resources',
'example-min.launch'), ad.launch)
159 self.assert_(isinstance(ad.interface, Interface))
160 self.assertEquals({}, ad.interface.subscribed_topics)
161 self.assertEquals({}, ad.interface.published_topics)
162 self.assertEquals([], ad.clients)
166 def fake_load_enoent(*args):
167 raise IOError(errno.ENOENT,
"fnf")
168 def fake_load_gen(*args):
171 load_actual = app_manager.app.load_AppDefinition_from_file
173 app_manager.app.load_AppDefinition_from_file = fake_load_enoent
176 self.fail(
"should have raised")
177 except NotFoundException:
pass 179 app_manager.app.load_AppDefinition_from_file = fake_load_gen
182 self.fail(
"should have raised")
183 except InternalAppException:
pass 185 app_manager.app.load_AppDefinition_from_file = load_actual
188 rospack = rospkg.RosPack()
189 rl_dir = rospack.get_path(
'roslaunch')
190 path = rospack.get_path(PKG)
191 test_dir = os.path.join(path,
'test')
195 self.assertEquals(
"foo/AppA", ad.name)
196 self.assertEquals(
"Android Joystick", ad.display_name)
197 self.assertEquals(
"Control the TurtleBot with an Android device", ad.description)
198 self.assertEquals(
"turtlebot", ad.platform)
200 self.assertEquals(os.path.join(test_dir,
'resources',
'example-min.launch'), ad.launch)
201 self.assert_(isinstance(ad.interface, Interface))
202 self.assertEquals({}, ad.interface.subscribed_topics)
203 self.assertEquals({}, ad.interface.published_topics)
204 self.assertEquals([], ad.clients)
209 rospack = rospkg.RosPack()
210 path = rospack.get_path(PKG)
211 test_dir = os.path.join(path,
'test')
214 self.assertEquals({}, empty.subscribed_topics)
215 self.assertEquals({}, empty.published_topics)
218 self.assertEquals({
'/camera/rgb/image_color/compressed':
'sensor_msgs/CompressedImage'}, test1.published_topics)
219 self.assertEquals({
'/turtlebot_node/cmd_vel':
'geometry_msgs/Twist'}, test1.subscribed_topics)
222 if __name__ ==
'__main__':
223 rosunit.unitrun(PKG,
'test_app', AppTest, coverage_packages=[
'app_manager.app'])
def load_AppDefinition_from_file(appfile, appname)
def test_load_Interface_from_file(self)
def find_resource(resource)
def test_AppDefinition(self)
def test_load_AppDefinition_by_name(self)
def test_load_AppDefinition_from_file(self)
def load_AppDefinition_by_name(appname)
def test_find_resource(self)
def load_Interface_from_file(filename)