Пример #1
0
class TestUnoService(TestCase):

    def setUp(self):
        self.instance = UnoService()
        self.defaults = UnoService.defaults
        self.options = Options(self.defaults['options'])
        self.env = env

    def test_options(self):
        """Check that the command line flags are properly handled"""
        for i in self.defaults['options']:
            assert getattr(self.options, i)

    def test_default_accept(self):
        """Make sure the accept string is set correctly"""
        assert self.instance.accept == self.defaults['accept'].format(host=self.defaults['host'],
                                                                      port=self.defaults['port'])

    def test_connect_string(self):
        """Make sure the connect string is set correctly"""
        assert self.instance.connectstr == self.defaults['connectstr'].format(host=self.defaults['host'],
                                                                      port=self.defaults['port'])
    def test_start_and_connect(self):
        """Make sure LibreOffice starts"""
        pid = self.instance.start()
        assert pid > 0
        desktop = self.instance.connect(try_start=False)
        assert desktop is not None

    def tearDown(self):
        try:
            self.instance.terminate()
        except:
            pass
Пример #2
0
 def setUp(self):
     self.instance = UnoService()
     self.defaults = UnoService.defaults
     self.options = Options(self.defaults['options'])
     self.env = env
Пример #3
0
def get_desktop(host='localhost', port=2002):
    """Get an instance of the UNO Desktop"""
    return UnoService(host=host, port=port).connect()