Example #1
0
    def test_dict_to_KeyValue(self):
        from turtlebot_app_manager.msg import KeyValue
        from turtlebot_app_manager.app_list import dict_to_KeyValue

        v = dict_to_KeyValue({})
        self.assertEquals([], v)

        v = dict_to_KeyValue({'a': 'b'})
        self.assertEquals([KeyValue('a', 'b')], v)

        v = dict_to_KeyValue({'a': 'b', 'c': 'd'})
        for ve in [KeyValue('a', 'b'), KeyValue('c', 'd')]:
            self.assert_(ve in v)

        # make sure that types convert
        v = dict_to_KeyValue({'a': 1})
        self.assertEquals([KeyValue('a', '1')], v)
Example #2
0
    def test_AppDefinition_to_App(self):
        from turtlebot_app_manager.msg import App, ClientApp, KeyValue
        from turtlebot_app_manager.app import AppDefinition, Client
        from turtlebot_app_manager.app_list import AppDefinition_to_App, dict_to_KeyValue

        ad = AppDefinition(name="appname", display_name="An App", 
                           description="Does something", platform="fakebot",
                           launch="file.launch", interface="file.interface", clients=[])
        a = AppDefinition_to_App(ad)
        self.assertEquals(a.name, 'appname')
        self.assertEquals(a.display_name, 'An App')
        self.assertEquals([], a.client_apps)

        client1 = Client('android',
                         {'manager1': 'data1'},
                         {'app1': 'data1'})
        ca = ClientApp('android', [KeyValue('manager1', 'data1')], [KeyValue('app1', 'data1')])
        ad = AppDefinition(name="appname", display_name="An App", 
                           description="Does something", platform="fakebot",
                           launch="file.launch", interface="file.interface", clients=[client1])
        a = AppDefinition_to_App(ad)
        self.assertEquals([ca], a.client_apps)

        client1 = Client('android',
                         {'manager1': 'data1', 'manager2': 'data2'},
                         {'app1': 'data1', 'app2': 'data2'})
        ca = ClientApp('android', dict_to_KeyValue(client1.manager_data), dict_to_KeyValue(client1.app_data))    
        ad = AppDefinition(name="appname", display_name="An App", 
                           description="Does something", platform="fakebot",
                           launch="file.launch", interface="file.interface", clients=[client1])
        a = AppDefinition_to_App(ad)
        self.assertEquals([ca], a.client_apps)

        client2 = Client('web', {},
                         {'app2': 'data2', 'app2b': 'data2b'})
        ca2 = ClientApp('web', [], dict_to_KeyValue(client2.app_data))  
        ad = AppDefinition(name="appname", display_name="An App", 
                           description="Does something", platform="fakebot",
                           launch="file.launch", interface="file.interface", clients=[client1, client2])
        a = AppDefinition_to_App(ad)
        self.assertEquals([ca, ca2], a.client_apps)