From e1f18a74449d22b2efef9e0c8e7aaa733c818dec Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 9 Mar 2018 15:32:09 +0100 Subject: [PATCH] Neue test-Methoden --- test/test_lock.py | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/test/test_lock.py b/test/test_lock.py index 9b0b19e..682f9b9 100755 --- a/test/test_lock.py +++ b/test/test_lock.py @@ -73,6 +73,34 @@ class TestLockHandler(WebHooksTestcase): "Class %r from %r imported.", 'LockHandler', 'webhooks.lock_handler') + # ------------------------------------------------------------------------- + def test_could_not_occupy_lockfile_error(self): + + LOG.info("Test raising a CouldntOccupyLockfileError exception ...") + + from webhooks.errors import CouldntOccupyLockfileError + + with self.assertRaises(CouldntOccupyLockfileError) as cm: + raise CouldntOccupyLockfileError('/var/lock/bla.lock', 9.1, 5) + e = cm.exception + LOG.debug("%s raised: %s", e.__class__.__name__, e) + + # ------------------------------------------------------------------------- + def test_object(self): + + LOG.info("Testing init of a simple object.") + + from webhooks.lock_handler import LockHandler + + locker = LockHandler( + appname='test_base_object', + verbose=self.verbose, + lockdir='/tmp', + ) + LOG.debug("LockHandler %%r:\n%r", locker) + LOG.debug("LockHandler %%s:\n%s", str(locker)) + + # ============================================================================= @@ -83,14 +111,16 @@ if __name__ == '__main__': if verbose is None: verbose = 0 init_root_logger(verbose) - + LOG.info("Starting tests ...") loader = unittest.TestLoader() suite = unittest.TestSuite() - + suite.addTest(TestLockHandler('test_import', verbose)) - + suite.addTest(TestLockHandler('test_could_not_occupy_lockfile_error', verbose)) + suite.addTest(TestLockHandler('test_object', verbose)) + runner = unittest.TextTestRunner(verbosity=verbose) result = runner.run(suite) @@ -98,7 +128,4 @@ if __name__ == '__main__': # ============================================================================= -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 LIST - - - +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list -- 2.39.5