summaryrefslogtreecommitdiff
path: root/talerbank
diff options
context:
space:
mode:
authorMS <ms@taler.net>2020-09-29 18:11:48 +0200
committerMS <ms@taler.net>2020-09-29 18:11:48 +0200
commitb5824b2aea107e284828be13df42d18985c110c0 (patch)
tree831ee5e2682781f96806a2b228b612e47dc2cc84 /talerbank
parent3dd9eb2430167b004a422589c18afb692da0661c (diff)
downloadbank-b5824b2aea107e284828be13df42d18985c110c0.tar.gz
bank-b5824b2aea107e284828be13df42d18985c110c0.tar.bz2
bank-b5824b2aea107e284828be13df42d18985c110c0.zip
Logging.
Tests log to a file, and remove print() statements in tests.
Diffstat (limited to 'talerbank')
-rw-r--r--talerbank/app/tests.py18
-rw-r--r--talerbank/app/views.py2
2 files changed, 8 insertions, 12 deletions
diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index ada3ed6..7597b63 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -43,11 +43,13 @@ from taler.util.amount import (
LOGGER = logging.getLogger()
LOGGER.setLevel(logging.DEBUG)
-
-# logging.disable(logging.CRITICAL)
-# re-enable: logging.disable(logging.NOTSET)
-#logging.disable(logging.NOTSET)
-
+LOGGER.handlers = [] # disable default console output.
+fileHandler = logging.FileHandler("tests.log") # put salt in filename.
+fileHandler.setLevel(logging.DEBUG)
+fileHandler.setFormatter(
+ logging.Formatter(fmt="%(asctime)-15s %(module)s %(levelname)s %(message)s")
+)
+LOGGER.addHandler(fileHandler)
def make_auth_line(username, password):
credentials = "%s:%s" % (username, password)
@@ -116,7 +118,6 @@ class WireGatewayTestCase(TestCase):
HTTP_AUTHORIZATION=make_auth_line("RandomExchange", "XYZ"),
)
self.assertEqual(r.status_code, 200)
- print(r.content.decode("utf-8"))
# Testing the "Integration API":
# has three operations: 1) /config, 2,3) create, see status of withdrawal.
@@ -212,7 +213,6 @@ class AccessAndIntegrationApiWithdrawTestCase(TestCase):
content_type="application/json"
)
self.assertEqual(r.status_code, 200)
- print(r.content.decode("utf-8"))
class AccessApiBalanceTestCase(TestCase):
def setUp(self):
@@ -229,7 +229,6 @@ class AccessApiBalanceTestCase(TestCase):
HTTP_AUTHORIZATION=make_auth_line("RandomUser", "XYZ"),
)
self.assertEqual(r.status_code, 200)
- print(r.content.decode("utf-8"))
class AccessApiTestingRegistrationTestCase(TestCase):
def setUp(self):
@@ -711,15 +710,12 @@ class BalanceTestCase(TestCase):
entries = json.loads(data)
acc_bal = SignedAmount(True, Amount(settings.TALER_CURRENCY, 10, 0))
- print("acc_bal start", acc_bal)
for entry in reversed(entries["data"]):
- print("entry", entry)
if entry["sign"] == "-":
acc_bal += SignedAmount.parse(entry["amount"])
if entry["sign"] == "+":
acc_bal -= SignedAmount.parse(entry["amount"])
- print("acc_bal after", acc_bal)
expected_amount = SignedAmount.parse(f"{settings.TALER_CURRENCY}:16.0")
self.assertEqual(acc_bal, expected_amount)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 689b395..8e8d9a9 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -852,7 +852,7 @@ def twg_add_incoming(request, user_account, acct_id):
amount = expect_json_body_amount(request, "amount")
debit_account_name = get_acct_from_payto(debit_account_payto)
- print(
+ LOGGER.info(
f"adding incoming balance to exchange ({acct_id}) from account {debit_account_payto} ({debit_account_name})"
)
debit_user = User.objects.get(username=debit_account_name)