gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-bank] 06/09: linting done with views


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] 06/09: linting done with views
Date: Tue, 05 Dec 2017 13:21:48 +0100

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

marcello pushed a commit to branch master
in repository bank.

commit 5745f9ee2c2007d69cbf51810de99ac3fe8bbb09
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Dec 5 12:48:23 2017 +0100

    linting done with views
---
 talerbank/app/tests.py | 36 ++++++++++++++++++------------------
 talerbank/app/views.py | 10 ++++------
 2 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index d249f13..3a74f5f 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -37,23 +37,23 @@ def clear_db():
 
 class WithdrawTestCase(TestCase):
     def setUp(self):
-        user_bankaccount = BankAccount(
-            user=User.objects.create_user(username="test_user",
-                                          password="test_password"),
-            account_no=100)
-        user_bankaccount.save()
-
-        exchange_bankaccount = BankAccount(
-            user=User.objects.create_user(username="test_exchange",
-                                          password=""),
-            account_no=99)
-        exchange_bankaccount.save()
+        BankAccount(
+            user=User.objects.create_user(
+                username="test_user",
+                password="test_password"),
+            account_no=100).save()
+
+        BankAccount(
+            user=User.objects.create_user(
+                username="test_exchange",
+                password=""),
+            account_no=99).save()
+        self.client = Client()
 
     @patch('hashlib.new') # Need to patch update() and hexdigest() methods.
     @patch('requests.post')
     @patch('time.time')
     def test_withdraw(self, mocked_time, mocked_post, mocked_hashlib):
-        client = Client()
         wire_details = '''{
             "test": {
                 "type":"test",
@@ -70,10 +70,10 @@ class WithdrawTestCase(TestCase):
             "reserve_pub": "UVZ789",
             "wire_details": wire_details.replace("\n", "").replace(" ", "")
         }
-        client.login(username="test_user", password="test_password")
+        self.client.login(username="test_user", password="test_password")
 
-        client.get(reverse("pin-question", urlconf=urls),
-                   params)
+        self.client.get(reverse("pin-question", urlconf=urls),
+                        params)
         # We mock hashlib in order to fake the CAPTCHA.
         hasher = MagicMock()
         hasher.hexdigest = MagicMock()
@@ -83,8 +83,8 @@ class WithdrawTestCase(TestCase):
         post.status_code = 200
         mocked_post.return_value = post
         mocked_time.return_value = 0
-        client.post(reverse("pin-verify", urlconf=urls),
-                    {"pin_1": "0"})
+        self.client.post(reverse("pin-verify", urlconf=urls),
+                         {"pin_1": "0"})
         expected_json = {
             "reserve_pub": "UVZ789",
             "execution_date": "/Date(0)/",
@@ -329,7 +329,6 @@ class HistoryTestCase(TestCase):
             except (json.JSONDecodeError, KeyError):
                 data = {}
 
-            # FIXME print urls which break the test.
             self.assertEqual(data.get(ctx.expected_resp.get("field")),
                              ctx.expected_resp.get("value"))
             self.assertEqual(ctx.expected_resp.get("status"),
@@ -426,6 +425,7 @@ class MeasureHistory(TestCase):
         # Make sure logging level is WARNING, otherwise the loop
         # will overwhelm the console.
         for i in range(self.ntransfers):
+            del i # to pacify PEP checkers
             wire_transfer(Amount(settings.TALER_CURRENCY, 1),
                           self.user_bankaccount0,
                           self.user_bankaccount,
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 2a38279..eebb49f 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -49,10 +49,8 @@ from .schemas import (validate_pin_tan_args, 
check_withdraw_session,
 LOGGER = logging.getLogger(__name__)
 
 class DebtLimitExceededException(Exception):
-    def __init__(self, msg):
-        self.msg = msg
-    def __str__(self):
-        return self.msg
+    def __init__(self):
+        super().__init__("Debt limit exceeded")
 
 class SameAccountException(Exception):
     pass
@@ -532,7 +530,7 @@ def wire_transfer_exc_handler(view_func):
     return wraps(view_func)(_decorator)
 
 @wire_transfer_exc_handler
-def wire_transfer(amount, debit_account, credit_account, subject, **kwargs):
+def wire_transfer(amount, debit_account, credit_account, subject):
     LOGGER.info("%s => %s, %s, %s" %
                 (debit_account.account_no,
                  credit_account.account_no,
@@ -580,7 +578,7 @@ def wire_transfer(amount, debit_account, credit_account, 
subject, **kwargs):
                     " % json.dumps(debit_account.amount.dump()))
         LOGGER.info("%s's threshold is: '%s'.\
                     " % (debit_account.user.username, 
json.dumps(threshold.dump())))
-        raise DebtLimitExceededException("Debt limit exceeded")
+        raise DebtLimitExceededException()
 
     with transaction.atomic():
         debit_account.save()

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



reply via email to

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