2 from officehelper
import bootstrap
, BootstrapException
5 class OfficeHelperTest(unittest
.TestCase
):
6 """officehelper.py must provide:
7 Support of Windows, Mac OS X & GNU/Linux distributions
8 Customizable connection with 'delays' **kwarg
9 Reporting to console with 'report' **kwarg
10 Memory cleanup from soffice service
11 extra features may be:
12 Python source documentation
14 def test_default_config(self
):
15 # Check default timeout and number of attempts
16 # Stop LibreOffice running service
17 ctx
= bootstrap() # Default settings suffice to initialize the service
19 if ctx
: # stop soffice as a service
20 smgr
= ctx
.getServiceManager()
21 desktop
= smgr
.createInstanceWithContext("com.sun.star.frame.Desktop", ctx
)
23 self
.assertTrue(ctx
) # check for failure
25 def test_kwargs(self
):
26 # Wait differently for LO to start, request context 10 times
27 # Report processing in console
28 ctx
= bootstrap(delays
=[1,]*10, report
=print)
29 if ctx
: # stop soffice as a service
30 smgr
= ctx
.getServiceManager()
31 desktop
= smgr
.createInstanceWithContext("com.sun.star.frame.Desktop", ctx
)
35 def test_exception(self
):
36 # Raise BootstrapException and stop ALL PRESENT LibreOffice running services
37 with self
.assertRaises(BootstrapException
):
38 bootstrap(delays
=[0,], report
=print) # delays=[0,] must raise BootstrapException
41 if __name__
== "__main__":
50 # vim: set shiftwidth=4 softtabstop=4 expandtab