34 import roslib; roslib.load_manifest(PKG)
44 os.utime(filename,
None)
50 rospack = rospkg.RosPack()
51 path = rospack.get_path(PKG)
52 test_dir = os.path.join(path,
'test')
54 app_list = app_manager.AppList([os.path.join(test_dir,
'applist0')])
55 self.assertEquals([], app_list.get_app_list())
57 filename = os.path.join(test_dir,
'applist1')
58 app_list = app_manager.AppList([filename])
59 al = app_list.get_app_list()
60 self.assertEquals([], app_list.invalid_installed_files)
62 self.assertEquals(
'Android Joystick', al[0].display_name )
72 filename = os.path.join(test_dir,
'applistbad')
73 app_list = app_manager.AppList([filename])
74 al = app_list.get_app_list()
75 self.assertEquals([], al)
76 self.assertEquals(2, len(app_list.invalid_installed_files))
83 from app_manager
import InvalidAppException
88 inf = InstalledFile(filename)
89 self.failIf(inf._file_mtime
is None)
90 self.assertEquals(filename, inf.filename)
91 self.assertEquals(1, len(inf.available_apps))
92 self.assertEquals(
'Android Joystick', inf.available_apps[0].display_name)
102 for bad
in [
'app_manager/bad.installed',
'app_manager/bad2.installed']:
105 inf = InstalledFile(filename)
106 self.fail(
"should have thrown")
107 except InvalidAppException:
pass 110 from app_manager.msg
import KeyValue
114 self.assertEquals([], v)
117 self.assertEquals([KeyValue(
'a',
'b')], v)
120 for ve
in [KeyValue(
'a',
'b'), KeyValue(
'c',
'd')]:
121 self.assert_(ve
in v)
125 self.assertEquals([KeyValue(
'a',
'1')], v)
128 from app_manager.msg
import App, ClientApp, KeyValue
132 ad = AppDefinition(name=
"appname", display_name=
"An App",
133 description=
"Does something", platform=
"fakebot",
134 launch=
"file.launch", interface=
"file.interface", clients=[])
136 self.assertEquals(a.name,
'appname')
137 self.assertEquals(a.display_name,
'An App')
138 self.assertEquals([], a.client_apps)
140 client1 = Client(
'android',
141 {
'manager1':
'data1'},
143 ca = ClientApp(
'android', [KeyValue(
'manager1',
'data1')], [KeyValue(
'app1',
'data1')])
144 ad = AppDefinition(name=
"appname", display_name=
"An App",
145 description=
"Does something", platform=
"fakebot",
146 launch=
"file.launch", interface=
"file.interface", clients=[client1])
148 self.assertEquals([ca], a.client_apps)
150 client1 = Client(
'android',
151 {
'manager1':
'data1',
'manager2':
'data2'},
152 {
'app1':
'data1',
'app2':
'data2'})
154 ad = AppDefinition(name=
"appname", display_name=
"An App",
155 description=
"Does something", platform=
"fakebot",
156 launch=
"file.launch", interface=
"file.interface", clients=[client1])
158 self.assertEquals([ca], a.client_apps)
160 client2 = Client(
'web', {},
161 {
'app2':
'data2',
'app2b':
'data2b'})
163 ad = AppDefinition(name=
"appname", display_name=
"An App",
164 description=
"Does something", platform=
"fakebot",
165 launch=
"file.launch", interface=
"file.interface", clients=[client1, client2])
167 self.assertEquals([ca, ca2], a.client_apps)
170 if __name__ ==
'__main__':
171 rosunit.unitrun(PKG,
'test_app_list', AppListTest, coverage_packages=[
'app_manager.app_list'])
def AppDefinition_to_App(app_definition)
def find_resource(resource)
def get_default_applist_directory()
def test_dict_to_KeyValue(self)
def test_get_default_applist_directory(self)
def test_AppDefinition_to_App(self)
def test_InstalledFile(self)