summaryrefslogtreecommitdiff
path: root/talerbank/app/tests.py
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2017-11-18 11:15:55 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2017-11-18 11:15:55 +0100
commit6810ea2415409b543b0d2d1961b6fd048db13e8b (patch)
tree58bbd122bcc1b892935db407987498ddc26cf3b9 /talerbank/app/tests.py
parent7d6e222081930433444e79410a2a7d0bba96f808 (diff)
downloadbank-6810ea2415409b543b0d2d1961b6fd048db13e8b.tar.gz
bank-6810ea2415409b543b0d2d1961b6fd048db13e8b.tar.bz2
bank-6810ea2415409b543b0d2d1961b6fd048db13e8b.zip
check money was actually transferred via testcase
Diffstat (limited to 'talerbank/app/tests.py')
-rw-r--r--talerbank/app/tests.py55
1 files 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):