pyuno/PythonTest_pyuno_pytests_testofficehelper.mk |   13 +++++
 pyuno/qa/pytests/testofficehelper.py               |   50 +++++++++++++++++++++
 2 files changed, 63 insertions(+)

New commits:
commit 28a43d53b25c183a7997cc18819d6ee0c675df19
Author:     Alain Romedenne <[email protected]>
AuthorDate: Fri Mar 1 16:33:05 2024 +0100
Commit:     Hossein <[email protected]>
CommitDate: Sat May 11 11:25:44 2024 +0200

    Unit tests for officehelper.py
    
    Depend upon previous patch d8978a8c4ffabd6b36a691fd3e2df68563808234 for
    officehelper.py which fixed some glitches.
    
    Change-Id: Icc5c717d7f0f5a0a08202b6b57e475e7afe6f5c9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164195
    Reviewed-by: Hossein <[email protected]>
    Tested-by: Jenkins
    Tested-by: Hossein <[email protected]>

diff --git a/pyuno/PythonTest_pyuno_pytests_testofficehelper.mk 
b/pyuno/PythonTest_pyuno_pytests_testofficehelper.mk
new file mode 100644
index 000000000000..77aac9d0f00b
--- /dev/null
+++ b/pyuno/PythonTest_pyuno_pytests_testofficehelper.mk
@@ -0,0 +1,13 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+$(eval $(call gb_PythonTest_PythonTest,pyuno_pytests_testofficehelper))
+$(eval $(call 
gb_PythonTest_add_modules,pyuno_pytests_testofficehelper,$(SRCDIR)/pyuno/qa/pytests,\
+    testofficehelper \
+))
+# vim: set noet sw=4 ts=4:
\ No newline at end of file
diff --git a/pyuno/qa/pytests/testofficehelper.py 
b/pyuno/qa/pytests/testofficehelper.py
new file mode 100644
index 000000000000..be2c99d8daf8
--- /dev/null
+++ b/pyuno/qa/pytests/testofficehelper.py
@@ -0,0 +1,50 @@
+import unittest
+from officehelper import bootstrap, BootstrapException
+
+
+class OfficeHelperTest(unittest.TestCase):
+    """officehelper.py must provide:
+    Support of Windows, Mac OS X & GNU/Linux distributions
+    Customizable connection with 'delays' **kwarg
+    Reporting to console with 'report' **kwarg
+    Memory cleanup from soffice service
+    extra features may be:
+    Python source documentation
+    """
+    def test_default_config(self):
+        # Check default timeout and number of attempts
+        # Stop LibreOffice running service
+        ctx = bootstrap()  # Default settings suffice to initialize the service
+        #time.sleep(10)  # gve
+        if ctx:  # stop soffice as a service
+            smgr = ctx.getServiceManager()
+            desktop = 
smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
+            desktop.terminate()
+        self.assertTrue(ctx)  # check for failure
+
+    def test_kwargs(self):
+        # Wait differently for LO to start, request context 10 times
+        # Report processing in console
+        ctx = bootstrap(delays=[1,]*10, report=print)
+        if ctx:  # stop soffice as a service
+            smgr = ctx.getServiceManager()
+            desktop = 
smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
+            desktop.terminate()
+        self.assertTrue(ctx)
+
+    def test_exception(self):
+        # Raise BootstrapException and stop ALL PRESENT LibreOffice running 
services
+        with self.assertRaises(BootstrapException):
+            bootstrap(delays=[0,], report=print)  # delays=[0,] must raise 
BootstrapException
+
+
+if __name__ == "__main__":
+
+    unittest.main()
+
+    # ~ dir(__name__)
+    # ~ help(__name__)
+    # ~ help(bootstrap)
+    # ~ exit()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab

Reply via email to