gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-taler-util] 41/51: Doxygen-comment logger test cases


From: gnunet
Subject: [GNUnet-SVN] [taler-taler-util] 41/51: Doxygen-comment logger test cases.
Date: Mon, 23 Sep 2019 22:02:32 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository taler-util.

commit 403eb31e600cd3263c04ab0a8b21914d99e854bf
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Mar 11 18:01:03 2019 +0100

    Doxygen-comment logger test cases.
---
 python/log/test.py | 121 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 94 insertions(+), 27 deletions(-)

diff --git a/python/log/test.py b/python/log/test.py
index 6a94c1f..90e12c1 100755
--- a/python/log/test.py
+++ b/python/log/test.py
@@ -1,29 +1,29 @@
-#  This file is part of TALER
-#  (C) 2019 TALER SYSTEMS
+##
+# This file is part of TALER
+# (C) 2019 TALER SYSTEMS
 #
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License, or (at your option) any later
-#  version.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later
+# version.
 #
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Lesser General Public License for more details.
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License for more details.
 #
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free
-#  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-#  Boston, MA  02110-1301  USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA  02110-1301  USA
 #
-#  @author Marcello Stanisci
-#  @version 0.0
-#  @repository https://git.taler.net/copylib.git/
-#  This code is "copylib", it is versioned under the Git repository
-#  mentioned above, and it is meant to be manually copied into any
-#  project which might need it.
-
+# @author Marcello Stanisci
+# @version 0.0
+# @repository https://git.taler.net/copylib.git/
+# @brief This code is "copylib", it is versioned under the Git
+#        repository mentioned above, and it is meant to be
+#        manually copied into any project which might need it.
 
 from unittest import TestCase
 from gnunet_log import GnunetLogger as GL
@@ -39,6 +39,10 @@ from datetime import datetime
 # INFO = 20
 # DEBUG = 10
 
+
+##
+# Helper function that removes any logging definition from the
+# environment.
 def clean_env():
     if os.environ.get("GNUNET_FORCE_LOG"):
         del os.environ["GNUNET_FORCE_LOG"]
@@ -48,16 +52,30 @@ def clean_env():
         del os.environ["GNUNET_FORCE_LOGFILE"]
 
 
-# NOTE: no logs will appear on screen, as the setLevel
-# function is mocked (and the level specified won't be
-# made effective -- rather, only the very default level
-# (WARNING) will apply)!
+
+
+##
+# "mother" class of all the tests.  NOTE: no logs will appear
+# on screen, as the setLevel function is mocked (therefore the
+# level specified won't be made effective -- rather, only the
+# default level (WARNING) will apply)!
 class TestGnunetLog(TestCase):
+    ##
+    # Setup method; just take care of cleaning the environment.
     def setUp(self):
         clean_env()
 
+    ##
     # This function tests whether GNUNET_FORCE_LOGFILE
     # is correctly interpreted.
+    #
+    # @param self the object itself.
+    # @param mocked_FileHandler "mock" object that will
+    #        "pretend" to be the file handler where the
+    #        logging logic will register the logfile path.
+    # @param mocked_addHandler "mock" object on which the
+    #        logging logic is expected to register the @a
+    #        mocked_FileHandler.
     @patch("logging.Logger.addHandler")
     @patch("logging.FileHandler")
     def test_force_logfile(self, mocked_FileHandler, mocked_addHandler):
@@ -72,10 +90,17 @@ class TestGnunetLog(TestCase):
         mocked_FileHandler.assert_called_with(expected_filename)
         mocked_addHandler.assert_called_with(unused_mock)
 
+    ##
     # This function tests the very basic case, where no
     # env variable is set and no explicit loglevel is given
     # via the "setup()" method.  The expected result is that
     # the level is set to INFO.
+    #
+    # @param self the object itself.
+    # @param mocked_basicConfig "mock" object that substitutes
+    #        the real basicConfig.
+    # @param mocked_setLevel "mock" object that substitutes
+    #        the real setLevel.
     @patch("logging.Logger.setLevel")
     @patch("logging.basicConfig")
     def test_no_env_and_no_setup(self, mocked_basicConfig, mocked_setLevel):
@@ -87,9 +112,16 @@ class TestGnunetLog(TestCase):
         mocked_setLevel.assert_called_with(level=logging.INFO)
 
 
+    ##
     # This function tests the case where *only* the GNUNET_LOG
     # env variable is set -- not even the manual setup of the
-    # loglevel is put in place.
+    # loglevel - via a call to the "setup()" method - is put in place.
+    #
+    # @param self the object itself.
+    # @param mocked_basicConfig "mock" object that substitutes
+    #        the real basicConfig.
+    # @param mocked_setLevel "mock" object that substitutes
+    #        the real setLevel.
     @patch("logging.Logger.setLevel")
     @patch("logging.basicConfig")
     def test_non_forced_env(self, mocked_basicConfig, mocked_setLevel):
@@ -99,9 +131,16 @@ class TestGnunetLog(TestCase):
         gl.log("msg", gl.DEBUG)
         mocked_setLevel.assert_called_with(level=logging.ERROR)
 
+    ##
     # This function tests the case where *only* the GNUNET_FORCE_LOG
     # env variable is set -- not even the manual setup of the loglevel
     # is put in place.
+    #
+    # @param self the object itself.
+    # @param mocked_basicConfig "mock" object that substitutes
+    #        the real basicConfig.
+    # @param mocked_setLevel "mock" object that substitutes
+    #        the real setLevel.
     @patch("logging.Logger.setLevel")
     @patch("logging.basicConfig")
     def test_only_forced_env(self, mocked_basicConfig, mocked_setLevel):
@@ -111,8 +150,15 @@ class TestGnunetLog(TestCase):
         gl.log("msg", gl.DEBUG)
         mocked_setLevel.assert_called_with(level=logging.ERROR)
 
+    ##
     # This function tests the case where *only* the manual
     # loglevel setup is put in place.
+    #
+    # @param self the object itself.
+    # @param mocked_basicConfig "mock" object that substitutes
+    #        the real basicConfig.
+    # @param mocked_setLevel "mock" object that substitutes
+    #        the real setLevel.
     @patch("logging.Logger.setLevel")
     @patch("logging.basicConfig")
     def test_only_manual_loglevel_setup(self, mocked_basicConfig, 
mocked_setLevel):
@@ -124,9 +170,16 @@ class TestGnunetLog(TestCase):
         mocked_setLevel.assert_called_with(level=logging.ERROR)
 
 
+    ##
     # This function tests the case where *both* the manual loglevel
     # and the forced env variable are setup; the expected result is
     # that the forced variable wins over the manual setup.
+    #
+    # @param self the object itself.
+    # @param mocked_basicConfig "mock" object that substitutes
+    #        the real basicConfig.
+    # @param mocked_setLevel "mock" object that substitutes
+    #        the real setLevel.
     @patch("logging.Logger.setLevel")
     @patch("logging.basicConfig")
     def test_manual_loglevel_AND_forced_env(self, mocked_basicConfig, 
mocked_setLevel):
@@ -143,9 +196,16 @@ class TestGnunetLog(TestCase):
         gl.log("msg", gl.DEBUG)
         mocked_setLevel.assert_called_with(level=logging.ERROR)
 
+    ##
     # This function tests the case where *both* GNUNET_LOG and
     # the manual loglevel setup are put in place.  The expectation
     # is that the manual loglevel wins.
+    #
+    # @param self the object itself.
+    # @param mocked_basicConfig "mock" object that substitutes
+    #        the real basicConfig.
+    # @param mocked_setLevel "mock" object that substitutes
+    #        the real setLevel.
     @patch("logging.Logger.setLevel")
     @patch("logging.basicConfig")
     def test_manual_loglevel_AND_nonforced_env(self, mocked_basicConfig, 
mocked_setLevel):
@@ -157,9 +217,16 @@ class TestGnunetLog(TestCase):
         gl.log("msg", gl.DEBUG)
         mocked_setLevel.assert_called_with(level=logging.ERROR)
 
+    ##
     # This function tests the case where *both* GNUNET_LOG and
     # GNUNET_FORCE_LOG are defined.  The expectation is that the
     # forced variable wins.
+    #
+    # @param self the object itself.
+    # @param mocked_basicConfig "mock" object that substitutes
+    #        the real basicConfig.
+    # @param mocked_setLevel "mock" object that substitutes
+    #        the real setLevel.
     @patch("logging.Logger.setLevel")
     @patch("logging.basicConfig")
     def test_forced_env_AND_nonforced_env(self, mocked_basicConfig, 
mocked_setLevel):

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]