[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-taler-util] 28/51: Testing 4453 with unittest. First
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-taler-util] 28/51: Testing 4453 with unittest. First batch. |
Date: |
Mon, 23 Sep 2019 22:02:19 +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 4a606080c1994e198d42f296c99e8f70d46be582
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Feb 7 13:57:05 2019 +0100
Testing 4453 with unittest. First batch.
---
python/amount/README | 4 +++
python/log/{test.py => test.old} | 0
python/log/test_ut.py | 63 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+)
diff --git a/python/amount/README b/python/amount/README
new file mode 100644
index 0000000..2990bfe
--- /dev/null
+++ b/python/amount/README
@@ -0,0 +1,4 @@
+Run the tests with:
+
+# Just from this directory.
+$ python3 -m unittest
diff --git a/python/log/test.py b/python/log/test.old
similarity index 100%
rename from python/log/test.py
rename to python/log/test.old
diff --git a/python/log/test_ut.py b/python/log/test_ut.py
new file mode 100755
index 0000000..6d84190
--- /dev/null
+++ b/python/log/test_ut.py
@@ -0,0 +1,63 @@
+# 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 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
+#
+# @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.
+
+
+from unittest import TestCase
+from gnunet_log import GnunetLogger as GL
+import os
+from mock import patch
+import logging
+
+def clean_env():
+ if os.environ.get("GNUNET_FORCE_LOG"):
+ del os.environ["GNUNET_FORCE_LOG"]
+ if os.environ.get("GNUNET_LOG"):
+ del os.environ["GNUNET_LOG"]
+ if os.environ.get("GNUNET_FORCE_LOGFILE"):
+ del os.environ["GNUNET_FORCE_LOGFILE"]
+
+class TestGnunetLog(TestCase):
+ def setUp(self):
+ clean_env()
+
+ # 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.
+ #
+ # 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)!
+ @patch("logging.Logger.setLevel")
+ @patch("logging.basicConfig")
+ def test_env(self, mocked_basicconfig, mocked_setLevel):
+ # Double-check no env variable gets in the way.
+ assert None == os.environ.get("GNUNET_FORCE_LOG")
+ assert None == os.environ.get("GNUNET_LOG")
+ gl = GL("mock-style")
+ gl.log("msg", gl.INFO)
+ mocked_setLevel.assert_called_with(level=logging.INFO)
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [taler-taler-util] 30/51: Testing env var GNUNET_LOG., (continued)
- [GNUnet-SVN] [taler-taler-util] 30/51: Testing env var GNUNET_LOG., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 32/51: 4453. Testing mixed situation,, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 37/51: fix after file rename, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 38/51: 4453. Test GNUNET_FORCE_LOGFILE., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 50/51: Make tests work again., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 33/51: 4453. Test manual loglevel setup and nonforced env., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 27/51: syntax, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 34/51: 4453. Test for GNUNET_LOG and GNUNET_FORCE_LOG both defined., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 39/51: Log: fix line interval parsing (care about one number case.), gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 31/51: 4453. Test only manual loglevel setup., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 28/51: Testing 4453 with unittest. First batch.,
gnunet <=
- [GNUnet-SVN] [taler-taler-util] 43/51: Add a .dir-locals, el for configuring emacs for this project, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 44/51: ux, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 46/51: gitignore, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 36/51: Remove old test, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 45/51: rename., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 35/51: 4453. Fix GNUNET_FORCE_LOG priority., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 40/51: Doxygen-commenting gnunet_log.py, gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 41/51: Doxygen-comment logger test cases., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 42/51: Importing the Doxygen-commented config from the bank., gnunet, 2019/09/23
- [GNUnet-SVN] [taler-taler-util] 47/51: rename., gnunet, 2019/09/23