]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Neue test-Methoden
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 9 Mar 2018 14:32:09 +0000 (15:32 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 9 Mar 2018 14:32:09 +0000 (15:32 +0100)
test/test_lock.py

index 9b0b19eb91f565a4f1dcae0aa93ea3efeab349a1..682f9b932551b8c43555d50b9953b5257cb535e8 100755 (executable)
@@ -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