Example #1
0
    def test_Master(self):
        from roslaunch.core import Master
        old_env = os.environ.get('ROS_MASTER_URI', None)
        try:
            os.environ['ROS_MASTER_URI'] = 'http://foo:789'
            m = Master()
            self.assertEquals(m.type, Master.ROSMASTER)
            self.assertEquals(m.uri, 'http://foo:789')
            self.assertEquals(m, m)
            self.assertEquals(m, Master())
            
            m = Master(Master.ROSMASTER, 'http://foo:1234')
            self.assertEquals(m.type, Master.ROSMASTER)
            self.assertEquals(m.uri, 'http://foo:1234')
            self.assertEquals(m, m)
            self.assertEquals(m, Master(Master.ROSMASTER, 'http://foo:1234'))

            import xmlrpclib
            self.assert_(isinstance(m.get(), xmlrpclib.ServerProxy))
            m.uri = 'http://foo:567'
            self.assertEquals(567, m.get_port())
            self.failIf(m.is_running())

        finally:
            if old_env is None:
                del os.environ['ROS_MASTER_URI']
            else:
                os.environ['ROS_MASTER_URI'] = old_env
Example #2
0
    def test_Master(self):
        from roslaunch.core import Master
        old_env = os.environ.get('ROS_MASTER_URI', None)
        try:
            os.environ['ROS_MASTER_URI'] = 'http://foo:789'
            m = Master()
            self.assertEquals(m.type, Master.ROSMASTER)
            self.assertEquals(m.uri, 'http://foo:789')
            self.assertEquals(m, m)
            self.assertEquals(m, Master())
            
            m = Master(Master.ROSMASTER, 'http://foo:1234')
            self.assertEquals(m.type, Master.ROSMASTER)
            self.assertEquals(m.uri, 'http://foo:1234')
            self.assertEquals(m, m)
            self.assertEquals(m, Master(Master.ROSMASTER, 'http://foo:1234'))

            import xmlrpclib
            self.assert_(isinstance(m.get(), xmlrpclib.ServerProxy))
            m.uri = 'http://foo:567'
            self.assertEquals(567, m.get_port())
            self.failIf(m.is_running())

        finally:
            if old_env is None:
                del os.environ['ROS_MASTER_URI']
            else:
                os.environ['ROS_MASTER_URI'] = old_env
Example #3
0
def test_Master():
    from roslaunch.core import Master
    # can't verify value of is_running for actual master
    m = Master(uri='http://localhost:11311')
    assert m.type == Master.ROSMASTER
    m.get_host() == 'localhost'
    m.get_port() == 11311
    assert m.is_running() in [True, False]
    assert isinstance(m.get(), ServerProxy)
    assert isinstance(m.get_multi(), MultiCall)

    m = Master(uri='http://badhostname:11312')
    m.get_host() == 'badhostname'
    m.get_port() == 11312
    assert m.is_running() == False
def test_Master():
    from roslaunch.core import Master
    # can't verify value of is_running for actual master
    m = Master(uri='http://localhost:11311')
    assert m .type == Master.ROSMASTER
    m.get_host() == 'localhost'
    m.get_port() == 11311
    assert m.is_running() in [True, False]
    assert isinstance(m.get(), xmlrpclib.ServerProxy)
    assert isinstance(m.get_multi(), xmlrpclib.MultiCall)
    
    m = Master(uri='http://badhostname:11312')
    m.get_host() == 'badhostname'
    m.get_port() == 11312
    assert m.is_running() == False
Example #5
0
    def test_Master(self):
        from roslaunch.core import Master
        old_env = os.environ.get('ROS_MASTER_URI', None)
        try:
            os.environ['ROS_MASTER_URI'] = 'http://foo:789'
            m = Master()
            self.assertEquals(m.type, Master.ROSMASTER)
            self.assertEquals(m.uri, 'http://foo:789')
            self.assertEquals(m.auto, Master.AUTO_NO)
            self.assertEquals(m.log_output, False)
            self.assertEquals(m, m)
            self.assertEquals(m, Master())

            m = Master(Master.ROSMASTER, 'http://foo:1234', Master.AUTO_START)
            self.assertEquals(m.type, Master.ROSMASTER)
            self.assertEquals(m.uri, 'http://foo:1234')
            self.assertEquals(m.auto, Master.AUTO_START)
            self.assertEquals(m.log_output, False)
            self.assertEquals(m, m)
            self.assertEquals(
                m,
                Master(Master.ROSMASTER, 'http://foo:1234', Master.AUTO_START))

            import xmlrpclib
            self.assert_(isinstance(m.get(), xmlrpclib.ServerProxy))
            m.set_port(567)
            self.assertEquals(m.uri, 'http://foo:567/')
            self.failIf(m.is_running())

            try:
                m = Master(Master.ROSMASTER, 'http://foo:1234', False)
                self.fail("should have failed on invalid auto value")
            except:
                pass
            try:
                m = Master(Master.ROSMASTER, 'http://foo:1234', 123)
                self.fail("should have failed on invalid auto value")
            except:
                pass

        finally:
            if old_env is None:
                del os.environ['ROS_MASTER_URI']
            else:
                os.environ['ROS_MASTER_URI'] = old_env