gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-bank] 01/02: check money was actually transferred vi


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] 01/02: check money was actually transferred via testcase
Date: Sat, 18 Nov 2017 11:25:47 +0100

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

marcello pushed a commit to branch master
in repository bank.

commit 6810ea2415409b543b0d2d1961b6fd048db13e8b
Author: Marcello Stanisci <address@hidden>
AuthorDate: Sat Nov 18 11:15:55 2017 +0100

    check money was actually transferred via testcase
---
 talerbank/app/tests.py | 55 +++++++++++++++++++++++++++++---------------------
 1 file changed, 32 insertions(+), 23 deletions(-)

diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index 55bea32..0ef9aab 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -65,9 +65,7 @@ class WithdrawTestCase(TestCase):
           "reserve_pub": "UVZ789",
           "wire_details": wire_details.replace("\n", "").replace(" ", "")
         }
-        client.post(reverse("login", urlconf=urls),
-                    {"username": "test_user",
-                     "password": "test_password"})
+        client.login(username="test_user", password="test_password")
 
         response = client.get(reverse("pin-question", urlconf=urls),
                               params)
@@ -99,6 +97,32 @@ class WithdrawTestCase(TestCase):
         
mocked_post.assert_called_with("http://exchange.example/admin/add/incoming";,
                                        json=expected_json)
 
+    def tearDown(self):
+        clear_db()
+
+class InternalWireTransferTestCase(TestCase):
+
+    def setUp(self):
+        gm = BankAccount(user=User.objects.create_user(username='give_money',
+                                                       password="gm"))
+        gm.save()
+        tm = BankAccount(user=User.objects.create_user(username='take_money'),
+                         account_no=88)
+        tm.save()
+
+    def test_internal_wire_transfer(self):
+        client = Client()
+        client.login(username="give_money", password="gm")
+        client.post(reverse("profile", urlconf=urls),
+                    {"amount": 3.0,
+                     "counterpart": 88,
+                     "subject": "charity"})
+        tm = BankAccount.objects.get(account_no=88)
+        self.assertEqual(0, Amount.cmp(Amount(settings.TALER_CURRENCY, 3), 
tm.amount))
+
+    def tearDown(self):
+        clear_db()
+
 class RegisterTestCase(TestCase):
     """User registration"""
 
@@ -125,8 +149,8 @@ class RegisterTestCase(TestCase):
 class RegisterWrongCurrencyTestCase(TestCase):
     """User registration"""
 
-    # Activating this user with a faulty currency.
     def setUp(self):
+        # Note, config has KUDOS as currency.
         user_bankaccount = BankAccount(
             user=User.objects.create_user(username='Bank'),
             amount=Amount('WRONGCURRENCY'),
@@ -142,10 +166,6 @@ class RegisterWrongCurrencyTestCase(TestCase):
                                {"username": "test_register",
                                 "password": "test_register"},
                                follow=True)
-        # A currency mismatch is expected when the 100 KUDOS will be
-        # attempted to be given to the new user.
-        # This scenario expects a 500 Internal server error response to
-        # be returned.
         self.assertEqual(500, response.status_code)
 
 class LoginTestCase(TestCase):
@@ -162,21 +182,10 @@ class LoginTestCase(TestCase):
 
     def test_login(self):
         client = Client()
-        response = client.post(reverse("login", urlconf=urls),
-                               {"username": "test_user",
-                                "password": "test_password"},
-                               follow=True)
-        self.assertIn(("/profile", 302), response.redirect_chain)
-
-        # Send wrong password
-        response = client.post(reverse("login", urlconf=urls),
-                               {"username": "test_user",
-                                "password": "test_passwordoo"},
-                               follow=True)
-        # The current logic -- django's default -- returns 200 OK
-        # even when the login didn't succeed.
-        # So the test here ensures that the bank just doesn't crash.
-        self.assertEqual(200, response.status_code)
+        self.assertTrue(client.login(username="test_user",
+                                     password="test_password"))
+        self.assertFalse(client.login(username="test_user",
+                                      password="test_passwordii"))
 
 class AmountTestCase(TestCase):
 

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



reply via email to

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