]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Adding test for BaseDPXApplication.
authorFrank Brehm <frank.brehm@pixelpark.com>
Thu, 1 Feb 2024 16:34:04 +0000 (17:34 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Thu, 1 Feb 2024 16:34:04 +0000 (17:34 +0100)
test/test_10_base_app.py [new file with mode: 0755]

diff --git a/test/test_10_base_app.py b/test/test_10_base_app.py
new file mode 100755 (executable)
index 0000000..67c2ae4
--- /dev/null
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+'''
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2024 by Frank Brehm, Berlin
+@license: GPL3
+@summary: test script (and module) for unit tests on base application class
+'''
+
+import os
+import sys
+import logging
+
+from pathlib import Path
+
+try:
+    import unittest2 as unittest
+except ImportError:
+    import unittest
+
+# from babel.dates import LOCALTZ
+
+libdir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'lib'))
+sys.path.insert(0, libdir)
+
+from general import PpAdminToolsTestcase, get_arg_verbose, init_root_logger
+
+# from fb_tools.common import pp, to_str, is_sequence
+
+LOG = logging.getLogger('test-base-app')
+
+# =============================================================================
+class TestBaseApp(PpAdminToolsTestcase):
+
+    # -------------------------------------------------------------------------
+    def setUp(self):
+
+        self.test_dir = Path(__file__).parent.resolve()
+        self.base_dir = self.test_dir.parent
+        self._appname = 'test-base-app'
+
+    # -------------------------------------------------------------------------
+    def tearDown(self):
+
+        pass
+
+    # -------------------------------------------------------------------------
+    def test_import(self):
+
+        LOG.info("Testing import of pp_admintools.app ...")
+        import pp_admintools.app
+        LOG.debug(
+            "Version of pp_admintools.app: " + pp_admintools.app.__version__)
+
+    # -------------------------------------------------------------------------
+    def test_cursor_position(self):
+
+        LOG.info("Testing BaseDPXApplication.cursor_position() ...")
+        from pp_admintools.app import BaseDPXApplication
+
+        pos = BaseDPXApplication.cursor_position()
+        LOG.debug("Got {}.".format(pos))
+
+        print('0123456789', end='', flush=True)
+        pos = BaseDPXApplication.cursor_position()
+        print()
+        if pos.x != -1 and pos.y != -1:
+            LOG.debug("Got {}.".format(pos))
+            self.assertEqual(pos.x, 11)
+        else:
+            LOG.info("Could not detect position of screen cursor.")
+
+
+# =============================================================================
+if __name__ == '__main__':
+
+    verbose = get_arg_verbose()
+    if verbose is None:
+        verbose = 0
+    init_root_logger(verbose)
+
+    LOG.info("Starting tests ...")
+
+    suite = unittest.TestSuite()
+
+    suite.addTest(TestBaseApp('test_import', verbose))
+    suite.addTest(TestBaseApp('test_cursor_position', verbose))
+
+    runner = unittest.TextTestRunner(verbosity=verbose)
+
+    result = runner.run(suite)
+
+
+# =============================================================================
+
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4